jenkins-pipeline

Jenkins pipeline determine if a branch is for Bitbucket pull request

一世执手 提交于 2020-03-20 05:56:17
问题 I'm using Jenkins together with the Bitbucket branch source plugin. Everything works great, but I want to be able to run/exclude certain stages in my pipeline depending on whether the branch is associated with a pull request or not, such as: pipeline { stages { stage('build') { //compile } stage('package') { when { environment name: 'IS_PULL_REQUEST', value: 'true' } //create deployable package } } } Jenkins knows when the branch is for a PR because it merges the source with the target and

How to pass Extensible Choice parameter type to Jenkins pipeline?

血红的双手。 提交于 2020-03-16 08:10:42
问题 We upgraded our Jenkins plugins, and now our jobs that pass String types to called jobs that have extensible choice parameter are core dumping. Say I have Job1 calling Job2, and Job2 has an Extensible Choice type parameter called TARGET_VERSION, which is a Groovy script that gets all the successful job numbers of a certain job. I used to be able to do this from Job1 Job1: node('someNode') { stage('Call Job2') { build job: 'Job2', parameters: [string(name: 'TARGET_VERSION', value: '1.2')],

How to pass Extensible Choice parameter type to Jenkins pipeline?

霸气de小男生 提交于 2020-03-16 08:09:28
问题 We upgraded our Jenkins plugins, and now our jobs that pass String types to called jobs that have extensible choice parameter are core dumping. Say I have Job1 calling Job2, and Job2 has an Extensible Choice type parameter called TARGET_VERSION, which is a Groovy script that gets all the successful job numbers of a certain job. I used to be able to do this from Job1 Job1: node('someNode') { stage('Call Job2') { build job: 'Job2', parameters: [string(name: 'TARGET_VERSION', value: '1.2')],

Does active choice reactive parameter support hide fields option?

落爺英雄遲暮 提交于 2020-03-05 01:31:10
问题 I have the below pipeline: I want that once I choose in the InstllationType the value 'Recreate', some fields will disappear. is it possible to do it with an active choice parameter? if not, is there any other way for doing it? 来源: https://stackoverflow.com/questions/60248264/does-active-choice-reactive-parameter-support-hide-fields-option

How to pass Extensible Choice parameter “value” to Jenkins pipeline?

好久不见. 提交于 2020-03-04 05:04:04
问题 I posted How to pass Extensible Choice parameter type to Jenkins pipeline? and found an answer, that is, I least I don't get the core dump anymore. However, I have 2 follow up questions. Again I have 2 jobs, Job1 and Job2. Job1 just triggers Job2. Job2 has an extensible choice parameter called TARGET_VERSION which runs a script that shows Job1's successful build numbers. Here's the Groovy script import hudson.model.* BUILD_JOB_NAME = "Job1" def getBuildJob() { def buildJob = null Hudson

collect data from Jenkins pipeline parallel steps

家住魔仙堡 提交于 2020-03-03 01:08:13
问题 What would be the best way to collect data (such as pass/fail results) from parallel steps. What I've reached so far: #!groovy def fspam(name, spam){ spam[name] = "BEEN THERE TOO" } // pipeline node('slave'){ stage("test"){ targets = ["a", "b"] def tasks = [:] def spam = [:] targets.each{ tasks["${it}"] = { node('slave'){ echo "dry-run ${it}" spam[it] = "BEEN THERE" <--- works fspam(it) <--- fails } } } parallel tasks print("spam") print(spam) } } But it failed with: Also: groovy.lang

Stop Jenkins checking out Git URL in a Pipeline stage

*爱你&永不变心* 提交于 2020-02-28 05:54:21
问题 I have setup a Jenkins Declarative Pipeline job, and it pulls the Jenkinsfile from Git. I have a stage that is running on a another node (selected by a label), but it is trying to checkout the Jenkinsfile from Git too. How can I stop this behavior? This particular slave is on the other side of a firewall and I can only reach it by SSH. 回答1: You can use the skipDefaultCheckout() in the options block. This will disable the checkout of the SCM on any node in any stage, so you will have to do a

Stop Jenkins checking out Git URL in a Pipeline stage

你离开我真会死。 提交于 2020-02-28 05:54:17
问题 I have setup a Jenkins Declarative Pipeline job, and it pulls the Jenkinsfile from Git. I have a stage that is running on a another node (selected by a label), but it is trying to checkout the Jenkinsfile from Git too. How can I stop this behavior? This particular slave is on the other side of a firewall and I can only reach it by SSH. 回答1: You can use the skipDefaultCheckout() in the options block. This will disable the checkout of the SCM on any node in any stage, so you will have to do a

How to use job import plugin in jenkins

元气小坏坏 提交于 2020-02-27 08:24:29
问题 I don't have access to both servers so cli is not an option only jenkins ui is available. I need to import jobs using job import plugin but i am unable to figure how to configure the plugin so as to import jobs. Could anyone please help me with this. 回答1: To configure the Jenkins Remote Plugin, you need to add a Jenkins Server to import your jobs. Setting a Jenkins Server To add a Jenkins Server you need to go on your Jenkins configuration: Manage Jenkins > Configure System > Job Import

How to use job import plugin in jenkins

偶尔善良 提交于 2020-02-27 08:24:08
问题 I don't have access to both servers so cli is not an option only jenkins ui is available. I need to import jobs using job import plugin but i am unable to figure how to configure the plugin so as to import jobs. Could anyone please help me with this. 回答1: To configure the Jenkins Remote Plugin, you need to add a Jenkins Server to import your jobs. Setting a Jenkins Server To add a Jenkins Server you need to go on your Jenkins configuration: Manage Jenkins > Configure System > Job Import