Skip to content

Instantly share code, notes, and snippets.

@shadow1163
Created April 30, 2019 10:58
Show Gist options
  • Save shadow1163/44e6a6000086bb4febf227009d08e9c3 to your computer and use it in GitHub Desktop.
Save shadow1163/44e6a6000086bb4febf227009d08e9c3 to your computer and use it in GitHub Desktop.
pipeline script with gitlab
properties([
parameters ([
//Global
choice(
name: 'environment',
choices: 'qa\nstaging\nproduction',
description: 'testing environment'
),
choice(
name: 'region',
choices: 'deu\nusa\njpn',
description: 'This parameter just ONLY valid for production environment'
),
])
])
def status = ‘’
node('!master') {
try {
stage('Test') {
sh 'echo "!";exit 0'
}
echo 'This will run only if successful'
status = ‘success’
} catch (e) {
echo 'This will run only if failed'
status = ‘failed’
// Since we're catching the exception in order to report on it,
// we need to re-throw it, to ensure that the build is marked as failed
throw e
} finally {
println(currentBuild.currentResult)
updateGitlabCommitStatus name: 'build', state: status
//println(currentResult)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment