jenkins-pipeline

How do I tag the current git changeset from inside the Jenkinsfile?

浪尽此生 提交于 2019-12-18 12:28:34
问题 I want to tag the current git changeset and push the tag from inside the Jenkinsfile. If the tag already exists it must be replaced. I want to use this logic in order to tag the build that passed with the snapshot tag, which would be a mobile tag. How can I do this? 回答1: Here is the way I was able to implement this this way, but if you know a better way I am more than willing to hear it. #!groovy stage 'build' node { repositoryCommiterEmail = 'ci@example.com' repositoryCommiterUsername =

How to view Jenkins workspace on a Pipeline job?

喜你入骨 提交于 2019-12-18 11:40:00
问题 How can I view Jenkins workspace on a Pipeline job (it was called workflow job previously)? In a standard Job I could just go to the Job main page and view it by clicking on "Workspace". 回答1: Go to the Jenkins build On the left hand side click the Pipeline steps Then on the right click on the link that says "Allocate node : Start - (x min in block)" On the the left side click the workspace. Done! The image below might help : Check out this link it shows how to get the workspace when you are

Run Parts of a Pipeline as Separate Job

我的梦境 提交于 2019-12-18 11:33:03
问题 We're considering using the Jenkins Pipeline plugin for a rather complex project consisting of several deliveries that need to be build using different tools (on different machines) before being merged. Still, it seems to be easy enough to do a complete build with a single Jenkinsfile , and I like the automatic discovery of git branches that comes with Pipeline. However, at this point, we have jobs for each of the deliveries and use a build-flow based "meta" job to orchestrate the individual

Matrix configuration with Jenkins pipelines

断了今生、忘了曾经 提交于 2019-12-18 10:50:55
问题 The Jenkins Pipeline plugin (aka Workflow) can be extended with other Multibranch plugins to build branches and pull requests automatically. What would be the preferred way to run multiple configurations? For example, building with Java 7 and Java 8. This is often called matrix configuration (because of the multiple combinations such as language version, framework version, ...) or build variants. I tried: executing them serially as separate stage steps. Good, but takes more time than

How to direct jenkins pipeline stage execution to a particular node agent derived from parameter?

末鹿安然 提交于 2019-12-18 09:38:04
问题 I have multipe Jenkins node agents, including "master", "tiering_agent1", and "cirrus". I am trying to set the node on which a Stage is executed by a parameters{} setting. I have this pipeline code def BuildAgentLabel='tiering_agent1' pipeline { agent { label 'master' } parameters { string( name: 'NEW_LABEL', defaultValue: '', description: '' ) } stages { stage( 'Init') { steps { script { if ( params.NEW_LABEL != '' ){ echo "Setting BuildAgentLabel to '${params.NEW_LABEL}'" BuildAgentLabel =

Currying groovy CPS closure for parallel execution

最后都变了- 提交于 2019-12-18 07:41:42
问题 We do some dynamic creation of parallel steps in some of our jobs. Thanks to this thread I found how to dynamically create the map with parameters for use in the parallel step. However now I wanted to reuse parts of the code which is used to create those parallel steps. For this I feel that I would need to curry the closures. However currying seems not to work correctly. Referencing the loop variable (valueCopy) inside the closure does the right thing (as mentioned here) but currying does not

Jenkins Build Periodically - Schedule

眉间皱痕 提交于 2019-12-18 05:53:39
问题 I am looking to build periodically every 15 minutes. I have looked online and I am using this schedule: */15 * * * * Jenkins is telling me to spread load evenly by using H/15 * * * * rather than */15 * * * * Could someone tell me the difference between using H instead of * ? 回答1: Yes. From the Build Triggers → Build periodically → Schedule → inline help: To allow periodically scheduled tasks to produce even load on the system, the symbol H (for “hash”) should be used wherever possible. For

Execute SonarQube Scanner within Jenkins 2 Pipeline

南笙酒味 提交于 2019-12-18 04:21:47
问题 I want to execute a "SonarQube Scanner" Step within my Jenkins 2.x Pipeline. When I try to create a sample groovy within the pipeline-syntax I only get a groovy script of the following format: step <object of type hudson.plugins.sonar.SonarRunnerBuilder> Does anyone know what is the correct Step Syntax? E.g. Publish JUnit Report looks like step([$class: 'JUnitResultArchiver', testResults: '']) I use the following Versions: Jenkins 2.11 SonarQube Scanner 2.6.1 SonarQube Plugin 2.4.1 回答1: I

Jenkins Multibranch pipeline: What is the branch name variable?

对着背影说爱祢 提交于 2019-12-18 03:02:01
问题 I'm new to the Jenkins Pipeline plugin, and especially new to the multibranch pipeline plugin. In a standard build I have access to the $GIT_BRANCH variable to know which branch is being built. However that variable isn't set in the multibranch pipeline. I have tried env.GIT_BRANCH too, and I tried to pass $GIT_BRANCH as a parameter to the build. Nothing seems to work. I assumed that since the build knows about the branch being built (I can see the branch name at the top of the console output

How can I execute Shell script in Jenkinsfile?

狂风中的少年 提交于 2019-12-18 01:32:47
问题 I am keeping a shell script file named urltest.sh in /var/lib/jenkins and executing the file from jenkins build. When I execute the build, It fails. The Environment Variables are - HOME - /var/lib/jenkins ; JENKINS_HOME - /var/lib/jenkins The console output comes as: Started by user anonymous Building in workspace /var/lib/jenkins/workspace/AutoScript [AutoScript] $ /bin/sh -xe /tmp/hudson2777728063740604479.sh + sh urltest.sh sh: 0: Can't open urltest.sh Build step 'Execute shell' marked