jenkins - Declarative Pipeline When Conditions -


i'm in need of when condition on jenkins. want take words full_build merge request title , execute different stages based on whether full_build or submitting merge request master doesn't need go through veracode, sonarqube, etc etc (these stages not pasted in repeats of when conditions below). however, have repeat crazy when condition on every stage, creating special stage executes on full_build or "regular" builds.

has created @noncps script set true/false variable? or there crafty way execute script on startup set reusable variable?

i want have users execute gitlab mr , not have go jenkins hit button (hence not use parameter of boolean).

pipeline {     agent {         node {             label 'master'         }     }      parameters{         //i trying pull information full build merge request     }      environment {         //assume random variables work fine     }      options {         skipdefaultcheckout()          gitlabconnection('gitlab_generic')           timeout(time: 60, unit: 'minutes')     }     triggers {         gitlab(triggeronpush: true, triggeronmergerequest: true, branchfiltertype: 'all')     }      stages {         stage('checkout') {             steps {                 checkout scm             }         }           stage('build') {              steps {                  dir("${env.workspace}\\${params.project_name}") {                     bat 'nuget.exe restore %project_name%.sln'                 }                  dir("${env.workspace}\\${params.project_name}\\build") {                     bat "\"${tool 'msbuild'}\"  %component%.xml  /p:configuration=debug "                  }                  dir("${env.workspace}") {                     echo "creating build status file"                     writefile file: "output/mr_title.txt", text: "build status:"                 }             }         }          stage('check mr full_build' ){             when {                      branch 'master'                   }             steps{                 dir("${env.workspace}") {                     //writefile file: "mr_title.txt", text: "build status:"                    powershell '& "./build/scripts/mergerequestapi.ps1" -git_credentials $env:git_api_token -project_id $env:git_project_id | out-file output/mr_title.txt -encoding utf8"'                    }             }         }           stage('package snapshot') {             when {                          allof  {                         branch 'master'                               not {                             expression {                                 return readfile('output/mr_title.txt').contains("full build")                             }                         }                     }                    }                     steps {                     dir("${env.workspace}\\${params.project_name}\\build") {                         bat "\"${tool 'msbuild'}\"  %component%.xml /t:publish /p:version=${env.snapshotcomponentversion} "                    }                 }             }           stage('package full build') {             when {                      allof  {                     branch 'master'                           expression {                         return readfile('output/mr_title.txt').contains("full build")                     }                                   }                }              steps {                     dir("${env.workspace}\\${params.project_name}\\build") {                           bat "\"${tool 'msbuild'}\"  %component%.xml /t:publish /p:version=${env.componentversion} "                 }             }         }     } } 


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -