Jenkins

Jenkins pipeline - how to load a Jenkinsfile without first calling node()?

喜夏-厌秋 提交于 2021-01-28 09:00:40
问题 I have a somewhat unique setup where I need to be able to dynamically load Jenkinsfiles that live outside of the src I'm building. The Jenkinsfiles themselves usually call node() and then some build steps. This causes multiple executors to be eaten up unnecessarily because I need to have already called node() in order to use the load step to run a Jenkinsfile, or to execute the groovy if I read the Jenkinsfile as a string and execute it. What I have in the job UI today: @Library(value=

Sed command ignoring single quotes in Groovy scripts

谁说胖子不能爱 提交于 2021-01-28 08:27:26
问题 Hello I am facing this issue when I try to replace string using SED in Groovy, it's ignoring the Single quotes which I am passing. Here is my code I tried using double quotes inside sed and it's throwing errors. stage('Version') { dir('./Dest/Scripts/') { sh "sed -i 's/VERSION_BUILD=0/VERSION_BUILD= '$Version', System2 = '$name'/g' setversion.sql" } } My desired output is UPDATE &Shared_Version SET SharedVersion = '2010', System1 = 'XXXX', InetsoftVersion = 2, VERSION_BUILD='20180302',

Jenkins Groovy: Update the labels in all nodes

别来无恙 提交于 2021-01-28 06:30:55
问题 I have a few hundred jenkins nodes and need to update the labels in all of them. It seems the easiest would be to run a groovy script in the Jenkins master script console that would add the extra label to each node's config. Question: How would one do this in groovy? 来源: https://stackoverflow.com/questions/56207343/jenkins-groovy-update-the-labels-in-all-nodes

How to delete original jenkins build after archiving the build

北城余情 提交于 2021-01-28 06:26:30
问题 I am using below Jenkinsfile to create maven build and archive it after. pipeline { agent any stages { stage('Build') { steps { withMaven(maven: 'mvn installed') { sh "mvn clean package" } } post { success { archiveArtifacts 'target/*.jar' } } } } After archiving the build it gets saved to target folder which has the jar file I want to use. However the build folder also contains the original com.. folder that contains the same jar. Is there any way I can delete this com folder after archiving

Error while executing another process through Groovy script

若如初见. 提交于 2021-01-28 05:30:23
问题 I'm invoking another process through Groovy script of Jenkins pipeline. Following is simple one script - pipeline { agent {label 'xxx.xxx.xx.xx} stages { stage('Test') { steps { script { sh 'pwd' def path = "pwd".execute().text } } } } } sh 'pwd' works perfectly fine. However "pwd".execute().text results into following error - java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.<init>

Jenkins Pipeline - inserting variable in shell creates a new line

喜欢而已 提交于 2021-01-28 05:25:37
问题 I am using Choice param in my jenkins file to select environment as follows: pipeline { agent any parameters { choice( name: 'ENVIRONMENT_URL', choices: "https://beta1.xyz.com\nhttps://beta2.xyz.com\nhttps://beta3.xyz.com", description: 'interesting stuff' ) } in the Stage section, i have the following piece stage('execute tests') { steps { script { sh """URL=${ENVIRONMENT_URL} npm run e2e:tests""" sh 'echo -e "\nTest Run Completed.\n"' } } } However, when i run the pipeline job by selecting

Trigger multiple Jenkins builds with GitHub Pull Request Builder

雨燕双飞 提交于 2021-01-28 04:34:13
问题 Currently, I have a Jenkins job setup so that when a pull request is opened for my repository, a Jenkins job is automatically created via the GitHub Pull Request Builder Plugin. I would like to be able to trigger multiple Jenkins jobs when a PR is opened in my GitHub repository and have the GitHub Pull Request Builder report the status back to the PR. Is this achievable via the GitHub Pull Request Builder plugin or are there other plugins available for this? My research has me coming up empty

Skip Build failure in maven if the integration test fails

こ雲淡風輕ζ 提交于 2021-01-28 03:10:08
问题 I want to skip the build failure even if the integration test fails. I am using maven-failsafe for Integration test. I am currently getting the following: Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.15:verify (default) on project xxxxx: There are test failures. Question : Can I use the following for Maven Failsafe Plugin? I know it works for the Surefire plugin, but not sure for failsafe. -Dmaven.test.failure.ignore=true 回答1: Yes, the same parameter is valid for

Trigger Jenkins Job only when changes happen to a particular branch

寵の児 提交于 2021-01-28 03:01:41
问题 I have configured a jenkins job and I wish it should be triggered when I make some changes to the Github for that particular branch. I use the Github plugin and has enabled "build when a change is pushed to github". But this option is triggering my Job if someone else create a separate branch and push to that branch. Let me explain it below: Change pushed to branch "release" Jenkins notified and job executes - Expected behavior Another change is now pushed to branch "xyz" but I don't intend