pipeline { options { disableConcurrentBuilds() gitLabConnection('Gitlab at Forge') gitlabBuilds(builds: ["Resolve", "Validate"]) } agent any environment { def resolveSucceded = "false" } stages { stage('Resolve') { steps{ sh 'echo Resolve stage' updateGitlabCommitStatus name: 'Resolve', state: 'pending' dir('apis') { checkout changelog: true, poll: false, scm: [ $class: 'GitSCM', branches: [[name: "${env.gitlabAfter}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PreBuildMerge', options: [ fastForwardMode: 'FF', mergeRemote: 'origin', mergeStrategy: 'DEFAULT', mergeTarget: "${env.gitlabTargetBranch}"]] ], submoduleCfg: [], userRemoteConfigs: [[ credentialsId: 'f9a9fd70-ea8b-4872-a9d5-d1fb1cf8123e', url: "${env.gitlabSourceRepoSshUrl}" ]] ] sh 'git log --oneline -n 5' sh 'git status -sb' } dir('scripts'){ checkout changelog: false, poll: false, scm: [ $class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[ credentialsId: 'f9a9fd70-ea8b-4872-a9d5-d1fb1cf8123e', url: 'git@forge.etsi.org:cti/forge-tools/3gpp-scripts.git']] ] } updateGitlabCommitStatus name: 'Resolve', state: 'success' script { env.resolveSucceded = "true" } } } stage('Validate') { steps{ updateGitlabCommitStatus name: 'Validate', state: 'pending' sh 'echo Validate stage' sh 'bash ./scripts/validate-all.sh ./apis' updateGitlabCommitStatus name: 'Validate', state: 'success' } } stage('Deploy to FTP') { steps{ sh 'echo DEPLOY stage' } } } post { failure { script { if (env.resolveSucceded == "false") { updateGitlabCommitStatus name: 'Resolve', state: 'failed' } } updateGitlabCommitStatus name: 'Validate', state: 'failed' mail to: 'cti_support@etsi.org', subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", body: "Something is wrong with ${env.BUILD_URL}" } } }