pipeline {
agent {
label 'slave-01'
}
stages {
// NOTE: this a one-way authentication process, only GitLab can forwards change to Jenkins
stage('Build') {
steps {
echo 'Build...'
// updateGitlabCommitStatus name: 'build', state: 'pending'
// updateGitlabCommitStatus name: 'build', state: 'success'
script {
sh '''
chmod u+x. /test-cmd.sh && ./test-cmd.sh
hostname
uptime
'''
}
}
}
stage('Test') {
steps {
echo 'Testing...'
}
}
}
post {
// Always runs. And it runs before any of the other post conditions.
always {
// Let's wipe out the workspace before we finish!
deleteDir()
}
}
// The options directive is for configuration that applies to the whole job.
options {
// For example, we'd like to make sure we only keep 10 builds at a time, so
// we don't fill up our storage!
buildDiscarder(logRotator(numToKeepStr: '10'))
// And we'd really like to be sure that this build doesn't hang forever, so
// let's time it out after half an hour.
timeout(time: 3, unit: 'MINUTES')
}
}