Skip to content

Instantly share code, notes, and snippets.

@caffeinetiger
Last active April 18, 2022 16:55
Show Gist options
  • Save caffeinetiger/9f4c0e7566697381557a5de758b2dce5 to your computer and use it in GitHub Desktop.
Save caffeinetiger/9f4c0e7566697381557a5de758b2dce5 to your computer and use it in GitHub Desktop.
For use in a Jenkins freestyle job in an Execute shell Build Action. Will run tests in a docker conatainer, check if there is a failed test and exit, and produce a .trx results file for Jenkins. Something to note is that the .trx file has to be cho
#!/bin/bash
set -e
TEST_OUTPUT=`docker run --rm -v $WORKSPACE:/src/ mcr.microsoft.com/dotnet/sdk:3.1 bash -c "cd /src/; dotnet test --logger 'trx;logfilename=testResults.trx';"`
sudo chown -R jenkins:jenkins .
FAIL_STR="Failed:"
ls -al
if [[ "$TEST_OUTPUT" == *"$FAIL_STR"* ]]; then
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment