updateGitlabCommitStatus name: 'Jenkins', state: 'pending' pipeline { environment { imageRepo = "asadullahkhan/poc-backend" registryCredential = 'docker' dockerImage = '' } agent any stages { stage('Cloning Git') { steps { git([url: 'https://github.com/AsadUkh/app-code-backend.git', branch: 'master']) updateGitlabCommitStatus name: "Jenkins", state: "running" sh "echo Source bracnh is ${gitlabSourceBranch}" } } stage('Build application') { steps { sh "npm install" } } stage('Building Docker image') { steps{ script { dockerImage = docker.build("$imageRepo:${env.BUILD_ID}") } } } stage('Push Image to Docker Hub') { steps{ script { dockerImage.push() } } } } post { always { script { try { echo "Helloworl integration with gitla" } catch(Exception ex) { echo "Unable to get pod name, may be no pods were created. Check previous steps for more logs. This is NOT a build error." } // archiveArtifacts artifacts: 'application.log' } } success { updateGitlabCommitStatus name: "Jenkins", state: "success" } failure { updateGitlabCommitStatus name: "Jenkins", state: "failed" } unstable { updateGitlabCommitStatus name: "Jenkins", state: "failed" } } }