Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yin042018/f7a65e9e9b93c828377ab939c5fbd6b6 to your computer and use it in GitHub Desktop.
Save yin042018/f7a65e9e9b93c828377ab939c5fbd6b6 to your computer and use it in GitHub Desktop.
a workaround for JENKINS-43995
// Jenkins Groovy pipeline code
// Runs rspec files
def RunSpec(specName) {
def rspeccommand = "rspec spec/" + specName + ".rb --colour --tty --format html --out " + specName + "_results.html --format documentation"
try {
sh rspeccommand
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: '.', reportFiles: specName + "_results.html", reportName: specName, reportTitles: specName])
} catch(err) {
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: '.', reportFiles: specName + "_results.html", reportName: specName, reportTitles: specName])
error 'FAIL' //sh "exit 1" // this fails the stage
}
} //end def RunSpec
node{
stage('git checkouts') {
checkout(...whatever you need here to checkout code...)
} //end stage('git checkouts')
try {
stage('Run Spec1') {
RunSpec('spec1')
}
} catch(err) {echo "Problem running Spec1 Tests"}
try {
stage('Run Spec2') {
RunSpec('spec3')
}
} catch(err) {echo "Problem running Spec2 Tests"}
try {
stage('Run Spec3') {
RunSpec('spec3')
}
} catch(err) {echo "Problem running Spec3 Tests"}
try {
stage('Run Spec4') {
RunSpec('spec4')
}
} catch(err) {echo "Problem running Spec4 Tests"}
} //node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment