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('data-models') { checkout changelog: true, poll: false, scm: [ $class: 'GitSCM', branches: [[name: "origin/${env.gitlabSourceBranch}"]], 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}" ]] ] } 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-data-models.sh ./data-models' updateGitlabCommitStatus name: 'Validate', state: 'success' } } stage('Lint') { steps{ updateGitlabCommitStatus name: 'Lint', state: 'pending' sh 'echo Lint stage' sh 'bash ./scripts/lint-data-models.sh ./data-models' updateGitlabCommitStatus name: 'Lint', 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}" } } }