Skip to content

Instantly share code, notes, and snippets.

@O5ten O5ten/Jenkinsfile
Last active Jun 16, 2019

Embed
What would you like to do?
Example jenkinsfile to test some arbitrary output in the log
pipeline {
parameters {
string(name: 'stuffToCheck', defaultValue: 'Test Failure!,Some Other Failure!', desription: 'CSV of stuff to check in the build-log')
}
stages {
stage('The thing'){
steps {
echo 'Test Failure!'
echo 'Some Other Failure!'
}
}
}
post {
always {
script {
def stuffToCheck = params.stuffToCheck.tokenize(',')
def logEntries = currentBuild.rawBuild.getLog(Integer.MAX_VALUE)
def violatingRows = logEntries.findAll { entry ->
stuffToCheck.any { thing -> entry.contains(thing) }
}
if(violatingRows) {
error """
failing build because of these rows:
======================
${violatingRows.join('\n')}
"""
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.