Skip to content

Instantly share code, notes, and snippets.

@klinki
Created February 10, 2018 22:20
Show Gist options
  • Save klinki/b73b4e76be460eed381a535f4e03ca14 to your computer and use it in GitHub Desktop.
Save klinki/b73b4e76be460eed381a535f4e03ca14 to your computer and use it in GitHub Desktop.
#!/usr/bin/env groovy
updateGitlabCommitStatus state: 'pending'
pipeline {
agent any
options {
// Here add name of your saved gitlab configuration with API key
gitLabConnection('Configured gitlab')
}
stages {
stage('Build') {
steps {
echo 'Building....'
updateGitlabCommitStatus state: 'running'
}
post {
success {
updateGitlabCommitStatus name: 'build', state: 'success'
}
failure {
updateGitlabCommitStatus name: 'build', state: 'failed'
}
}
}
stage('Test') {
steps {
echo 'Testing....'
}
post {
success {
updateGitlabCommitStatus name: 'tests', state: 'success'
}
failure {
updateGitlabCommitStatus name: 'tests', state: 'failed'
}
}
}
}
post {
always {
echo 'Always'
deleteDir() /* clean up our workspace */
}
success {
// Gitlab notification could go also here (if you don't need to distinguish between build and test phase)
// updateGitlabCommitStatus name: 'tests', state: 'success'
}
failure {
// Gitlab notification could go also here (if you don't need to distinguish between build and test phase)
// updateGitlabCommitStatus name: 'tests', state: 'success'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment