jenkins-workflow

Jenkins Pipeline throttle other jobs

北慕城南 提交于 2021-02-07 08:42:01
问题 I'm trying to lock some other jobs from runing when a jenkins pipeline is running, I've been trying to use the exclusion-plugin or the throttle-concurrent-builds-plugin with this kind of structure : node(){ stage "test" allocate('test') sleep time: 15, unit: 'MINUTES' sh "echo 'yes'" } @NonCPS def allocate(String resource){ throttle = new hudson.plugins.throttleconcurrents.ThrottleJobProperty( maxConcurrentPerNode=1, maxConcurrentTotal=1, categories = [resource], throttleEnabled=true,

How to set environment variable from a job and use it in next job in jenkins?

百般思念 提交于 2021-02-07 06:19:07
问题 I want to have a job to set the environment variable and use these environment variables in all the next jobs. How can I set environment variable through Jenkins ? 回答1: Technically, you can't pass env variables from one job to the next, and I'm not aware of a plugin to do that out of the box. There is a technique however. The idea is to create a properties file in the first job (e.g. exported.properties), add that file to the job artifacts, and then import this file via the EnvInject plugin

How to use Log Parser Plugin in a Jenkins Workflow script

空扰寡人 提交于 2021-01-23 08:56:29
问题 The Log Parser Plugin is now compatible with Workflow but how do I use it? 回答1: Easiest is to use Snippet Generator to get an example step statement using it. 回答2: Snippet Generator is a good idea; however, it is not generating the complete line to make it work. It is necessary to add at the end of the code line " , projectRulePath: '' ". Final line will be in the way, for example: logParser failBuildOnError: true, parsingRulePAth: '/myRulesPath', showGraphs:true, unstableOnWarning: true,

How to use Log Parser Plugin in a Jenkins Workflow script

末鹿安然 提交于 2021-01-23 08:55:42
问题 The Log Parser Plugin is now compatible with Workflow but how do I use it? 回答1: Easiest is to use Snippet Generator to get an example step statement using it. 回答2: Snippet Generator is a good idea; however, it is not generating the complete line to make it work. It is necessary to add at the end of the code line " , projectRulePath: '' ". Final line will be in the way, for example: logParser failBuildOnError: true, parsingRulePAth: '/myRulesPath', showGraphs:true, unstableOnWarning: true,

Preserve Jenkins workspace

我怕爱的太早我们不能终老 提交于 2020-06-12 04:40:26
问题 I have Jenkins set up to run concurrent builds, so I end up with workspace, workspace@2, workspace@3, etc. If Jenkins thinks the build is finished, a new build will overwrite the workspace. Is there a way of occasionally preventing that? E.g. Don't overwrite workspace@3 until I say. We have various scenarios where this would be very useful. 回答1: You could simply archive the complete workspace at the end of a build. It would then get deleted when the job is deleted. To do this: Add post-build

Preserve Jenkins workspace

泄露秘密 提交于 2020-06-12 04:40:09
问题 I have Jenkins set up to run concurrent builds, so I end up with workspace, workspace@2, workspace@3, etc. If Jenkins thinks the build is finished, a new build will overwrite the workspace. Is there a way of occasionally preventing that? E.g. Don't overwrite workspace@3 until I say. We have various scenarios where this would be very useful. 回答1: You could simply archive the complete workspace at the end of a build. It would then get deleted when the job is deleted. To do this: Add post-build

Using failFast with closure map breaks “parallel” step

梦想的初衷 提交于 2020-06-10 07:36:02
问题 Not sure if it's my limited knowledge of Groovy or a quirk in Pipeline parallel step. I can't make it accept failFast if I use map instead of passing each closure individually: def map = [:] map['spam'] = { node { echo 'spam' } } map['eggs'] = { node { echo 'eggs' } } parallel map // Works. parallel spam: map['spam'], eggs: map['eggs'], failFast: true // Works. parallel map, failFast: true // Fails with exception. The exception with failFast is: java.lang.IllegalArgumentException: Expected

Trigger workflow on Github push - Pipeline plugin - Multibranch configuration

旧时模样 提交于 2020-05-24 17:36:47
问题 We are using the pipeline plugin with multibranch configuration for our CD. We have checked in the Jenkinsfile which works off git. git url: "$url",credentialsId:'$credentials' The job works fine, but does not auto trigger when a change is pushed to github. I have set up the GIT web hooks correctly. Interestingly, when I go into a branch of the multibranch job and I click "View Configuration", I see that the "Build when a change is pushed to Github" is unchecked. There is no way to check it

Jenkins Choice parameter Passing to a pipeline Job

╄→尐↘猪︶ㄣ 提交于 2020-04-07 18:41:11
问题 Currently I have a pipeline job which has different paramters where one of this parameters is a Choice parameter. Here is the config.xml output of that job parameter: <hudson.model.ChoiceParameterDefinition> <choices class="java.util.Arrays$ArrayList"> <a class="string-array"> <string>f1</string> <string>f2</string> <string>f3</string> <string>f4</string> </a> </choices> <name>WHERE</name> <description>Something</description> </hudson.model.ChoiceParameterDefinition> Now I can call this job

Jenkins Pipeline Step withEnv does not work without BASH

|▌冷眼眸甩不掉的悲伤 提交于 2020-02-24 17:01:45
问题 I've trouble setting an environment variable for a container in an Jenkins pipeline. It seems, that "withEnv" does not work nicely with machines without bash. Can you confirm that? I cannot find an official statement ;-) When I run the following snippet on the Jenkins slave it works. But when it is executed in a docker container without BASH "$test" isn't set. withEnv(["test='asd'"]){ sh 'echo $test' } https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#code-withenv-code-set