jenkins-pipeline

Jenkins Pipeline cannot execute SH command file in a Windows slave

余生颓废 提交于 2019-12-01 05:28:49
I'm executing this code: node('my_windows_slave') { sh 'ls' } In my Windows slave I can properly execute sh command: But the pipeline script can't run the .sh file: [Pipeline] sh [D:\workspace\sandbox_pipeline] Running shell script sh: D:\workspace\sandbox_pipeline@tmp\durable-2d7dd2f8\script.sh: command not found What I could notice is that this .sh file is not even created, once I tried with bat and worked fined. Any clue what could be the problem? [UPDATE] Jenkins somehow can't create the SH temporary file. Already checked the log, permissions, everything that came to my mind. I will leave

Jenkins Pipeline Syntax for “p4sync”

别说谁变了你拦得住时间么 提交于 2019-12-01 04:53:07
I'm trying to sync to Perforce in my pipeline script, but from the documentation I don't see a way to set the "workspace behavior", even though the plugin itself seems to have that capability . I want the "workspace" to be equivalent to the setting "Manual (custom view)" I can configure in the UI as described here . What parameters do I need to pass to the p4sync task to achieve that? You will need to use the full checkout DSL, the p4sync DSL is only basic. The easiest way is to use the snippet generator ( Pipeline Syntax link), select checkout: General SCM then Perforce Software from the SCM

Jenkins Multi-branch pipeline doesn't schedule tag jobs

安稳与你 提交于 2019-12-01 04:46:01
I'm trying to get Jenkins' multibranch pipeline job to build tags in a similar manner to branches. In Jenkins 2.73 (not sure when the functionality was added), Multibranch projects can be configured to retrieve both branches and tags from the source repository. Initially I thought this would be perfect for my needs (my Jenkinsfile can now build development or production builds from the same place in Jenkins). Multibranch job with tags discovery configured I have the build process itself up and running quite happily with a scripted pipeline, however my issue is that whilst the branch jobs

Jenkins Declarative Pipeline: How to inject properties

回眸只為那壹抹淺笑 提交于 2019-12-01 04:31:03
问题 I have Jenkins 2.19.4 with Pipeline: Declarative Agent API 1.0.1. How does one use readProperties if you cannot define a variable to assign properties read to? For example, to capture SVN revision number, I currently capture it with following in Script style: ``` echo "SVN_REVISION=\$(svn info ${svnUrl}/projects | \ grep Revision | \ sed 's/Revision: //g')" > svnrev.txt ``` def svnProp = readProperties file: 'svnrev.txt' Then I can access using: ${svnProp['SVN_REVISION']} Since it is not

Pass Jenkins build parameters to pipeline nodes

懵懂的女人 提交于 2019-12-01 04:25:42
I created a new Jenkins pipeline. The pipeline is (currently) parametrized with a single boolean option named VAR_A . My pipeline script is: node ('windows') { echo "$VAR_A" bat 'env' } When I manually build the project with VAR_A checked, "true" is echoed, as expected. The list of environment variables, however, does not show VAR_A=true . I am able to get env to show VAR_A if I wrap the call in a withEnv block: node ('windows') { echo "$VAR_A" withEnv(["VAR_A=$VAR_A"]) { bat 'env' } } I will more parameters than this, so specifying each parameter individually is not desired. Is there a way to

Post failure block in Jenkinsfile is not working

最后都变了- 提交于 2019-12-01 04:06:19
问题 I'm trying a post failure action with a parallel step but it never works. This is my Jenkinsfile: pipeline { agent any stages { stage("test") { steps { withMaven( maven: 'maven3', // Maven installation declared in the Jenkins "Global Tool Configuration" mavenSettingsConfig: 'maven_id', // Maven settings.xml file defined with the Jenkins Config File Provider Plugin mavenLocalRepo: '.repository') { // Run the maven build sh "mvn --batch-mode release:prepare -Dmaven.deploy.skip=true" --> it will

Jenkins - env: ‘node’: No such file or directory

*爱你&永不变心* 提交于 2019-12-01 03:42:37
问题 I have a jenkins server that is configured using https://github.com/shierro/jenkins-docker-examples/tree/master/05-aws-ecs I am running a blue ocean pipeline using a simple Jenkinsfile and the jenkins NodeJS plugin pipeline { agent any tools { nodejs 'node10' } stages { stage ('Checkout Code') { steps { checkout scm } } stage ('Install dependencies') { steps { sh "echo $PATH" sh "npm install" } } } } I made sure to add the node10 global tool as well w/c is used above When the pipeline gets to

Jenkins Pipeline cannot execute SH command file in a Windows slave

纵然是瞬间 提交于 2019-12-01 03:24:44
问题 I'm executing this code: node('my_windows_slave') { sh 'ls' } In my Windows slave I can properly execute sh command: But the pipeline script can't run the .sh file: [Pipeline] sh [D:\workspace\sandbox_pipeline] Running shell script sh: D:\workspace\sandbox_pipeline@tmp\durable-2d7dd2f8\script.sh: command not found What I could notice is that this .sh file is not even created, once I tried with bat and worked fined. Any clue what could be the problem? [UPDATE] Jenkins somehow can't create the

Determine Failed Stage in Jenkins Declarative Pipeline

泄露秘密 提交于 2019-12-01 03:19:44
How do I report the stage in which a declarative pipeline failed? In the fail block, I want to get failedStage.name and report it (eventually to slack). pipeline { agent { label 'master'} stages { stage('Ok') { steps { echo 'do thing' } } stage('NotOK') { steps { sh 'make fail' } } } post { always { echo 'ok' } failure { echo 'Failed during Which Stage?' } } } Instead of adding post section in every stage, I found some solution that shouldn't be working in Declarative Pipeline from my point of view, but it does. All is you need is to override stage : def stage(String name, Closure cl) { echo

Extracting part of a string on jenkins pipeline

ぃ、小莉子 提交于 2019-12-01 03:09:02
问题 I am having some trouble with the syntax in my pipeline script. I am trying to capture everything after the last forward slash "/" and before the last period "." in this string git@github.com:project/access-server-pd.git (access-server-pd) Here (below) is how I would like to set it up MYVAR="git@github.com:project/access-server-pd.git" NAME=${MYVAR%.*} # retain the part before the colon NAME=${NAME##*/} # retain the part after the last slash echo $NAME I have it current set up with triple