jenkins-pipeline

Jenkins Pipeline stage skip based on groovy variable defined in pipeline

柔情痞子 提交于 2020-08-27 21:41:50
问题 I'm trying to skip a stage based a groovy variable and that variable value will be calculated in another stage. In the below example, Validate stage is conditionally skipped based Environment variable VALIDATION_REQUIRED which I will pass while building/triggering the Job. --- This is working as expected. Whereas the Build stage always runs even though isValidationSuccess variable is set as false . I tried changing the when condition expression like { return "${isValidationSuccess}" == true ;

Allow promotion of job in Jenkins pipeline

痴心易碎 提交于 2020-08-27 07:15:10
问题 I have a Jenkins pipeline which is responsible for about 5 stages (build and several different tests). I'm migrating from Jenkins 1.XX (with no pipelines) to Jenkins 2 and I'd like to replicate my process as closely as possible. The pipeline job I have set up on J2 handles everything exactly the same except it's using a JenkinsFile. The only issue is that the pipeline plugin does not appear to support Promotion of particular builds like you can do with Freestyle Jobs. Has anyone found a way

No such DSL method 'when' found among steps in Jenkinsfile

徘徊边缘 提交于 2020-08-27 04:09:26
问题 I want to execute some stage in loop. I have Jenkinsfile pipeline { agent any tools {} parameters {} environment {} stages { stage('Execute') { steps { script { for (int i = 0; i < hostnameMap.size; i++) { hostname = hostnameMap[i] echo 'Executing ' + hostname stage('Backup previous build ' + hostname) { backup(hostname, env.appHome) } stage('Deploy ' + hostname) { when { expression { env.BRANCH_NAME ==~ /(dev|master)/ } } steps { script { deploy(hostname , env.appHome, env.appName) } } }

Jenkins REST API to get job and job console log

和自甴很熟 提交于 2020-08-22 06:19:06
问题 How to get the details of the job along with it console output using Jenkins REST API example of builds console output: I am using following commands to get the path of console log echo $JENKINS_HOME/jobs/$JOB_NAME/builds/${BUILD_NUMBER}/log echo $BUILD_URL/consoleText It would provide the path to console log http://localhost:8080/job/Echo/25//consoleText but if i try to get the data from it using c#.net it would through me a exception I am using following code to get the data public string

Jenkins REST API to get job and job console log

允我心安 提交于 2020-08-22 06:19:05
问题 How to get the details of the job along with it console output using Jenkins REST API example of builds console output: I am using following commands to get the path of console log echo $JENKINS_HOME/jobs/$JOB_NAME/builds/${BUILD_NUMBER}/log echo $BUILD_URL/consoleText It would provide the path to console log http://localhost:8080/job/Echo/25//consoleText but if i try to get the data from it using c#.net it would through me a exception I am using following code to get the data public string

Jenkins Pipeline: view logs of child build job

大兔子大兔子 提交于 2020-08-11 03:07:46
问题 I have a jenkins pipeline that is running a "job" as one of its stages. I am wondering, is there a way to see the logs of the build job in a pipeline, without clicking into the job and viewing the console output. It would just make it a lot easier to see the failures without some many clicks. 回答1: Yes there's a way how to do this, unfortuntaly it looks like it's not documented: The build returns an object of type RunWrapper which you can use to access the Run object via getRawBuild() .

Pass Groovy object into active choice parameter

回眸只為那壹抹淺笑 提交于 2020-08-10 19:17:50
问题 I use active choice reactive parameter with declarative pipeline. But I ran into a problem. Is there any way to pass list object into script or call external method? For example environments = 'lab\nstage\npro' List<String> someList = ['ccc', 'ddd'] def someMethod() { return ['aaa', 'bbb'] } properties([ parameters([ choice(name: 'ENVIRONMENT', choices: "${environments}"), [$class: 'CascadeChoiceParameter', choiceType: 'PT_SINGLE_SELECT', description: 'Select a choice', filterLength: 1,