jenkins-pipeline

How to get workspace of jenkins pipeline plugin job (WorkflowRun object java API )

我是研究僧i 提交于 2019-12-11 05:19:18
问题 In the java API, I can access to the workspace path from the Run.java object: (Until today, all objects were instance of hudson.model.AbstractBuild) hudson.model.AbstractBuild#getWorkspace() hudson.model.Run#getExecutor().getCurrentWorkspace() In Pipeline plugin I don’t have an access to the workspace, the run object is instance of org.jenkinsci.plugins.workflow.job.WorkflowRun and this object doesn’t link to any workspace. this call return null: hudson.model.Run#getExecutor()

Passing Jenkins environment variable in Powershell script

北慕城南 提交于 2019-12-11 05:13:57
问题 i would like to use a jenkins environment variable inside a power shell script.Here ${destination} is coming as null inside powershell script.Not able to identify what is the mistake i am doing.Please help !/bin/groovy pipeline { agent { label { label "" customWorkspace "C:\\Jenkins\\workspace" } } environment { def destination='' } options { timestamps() timeout(time: 60, unit: 'MINUTES') skipDefaultCheckout(true) disableConcurrentBuilds() } stages { stage('TEST') { steps { script{

Jenkins pipeline step happens on master instead of slave

末鹿安然 提交于 2019-12-11 05:13:33
问题 I am getting started with Jenkins Pipeline. My pipeline has one simple step that is supposed to run on a different agent - like the "Restrict where this project can be run" option. My problem is that it is running on master. They are both Windows machines. Here's my Jenkinsfile : pipeline { agent {label 'myLabel'} stages { stage('Stage 1') { steps { echo pwd() writeFile(file: 'test.txt', text: 'Hello, World!') } } } } pwd() prints C:\Jenkins\workspace\<pipeline-name>_<branch-name>

Jenkins Pipeline continue latest build at certain time

笑着哭i 提交于 2019-12-11 05:09:44
问题 I have a Jenkins Pipeline which runs per commit, does a build and runs some sanity tests. Then at 8pm I want the latest successful build to carry on and run more indepth tests as part of the same pipeline. I have looked at milestone and lock but it seem that the first commit of the day would grab the lock to wait till 8pm and then be "promoted" and then when that finished it would run the latest which doesnt work for me. I have looked at milestone and then having a user-input to hold all the

Jenkins Pipeline Maven Artifactory Plugin Cannot Resolve Artifact From Central Maven Repository

天涯浪子 提交于 2019-12-11 05:01:53
问题 When using a Jenkins Freestyle Project I am able to successfully run a build with Maven using the "Maven3-Artifactory Integration." When trying to use this feature in pipeline I run into issues with resolving artifacts from the central maven repository. I am under the impression that when Jenkins cannot find an artifact in artifactory it should fall back to the central maven repository,https://repo.maven.apache.org/maven2, to look for the artifact. Is this not the case? def server =

How to use Jenkins plugins with no pipeline support?

牧云@^-^@ 提交于 2019-12-11 04:54:27
问题 I have a plugin that I would like to call from a pipeline Jenkinsfile, but the plugin does not have pipeline support so it does not show up in the snippet generator. Is it still possible to use this plugin with a pipeline job; if so, how? Specifically, the plugin I'm trying to use is the Nexus IQ plugin. 回答1: No. From a Pipeline job you could use build('job-name') to build a Freestyle job which uses that plugin. But unless the plugin has added Pipeline support (which is usually pretty simple)

Jenkins calling groovy script security errors

我只是一个虾纸丫 提交于 2019-12-11 04:33:14
问题 I'm currently working on running bentolor's idea-cli-inspector in my pipeline for static analysis. Unfortunately, I cannot find any documentation on how to allow parameters using the "load" command, and this command works by bringing in source anyway, so I made my own function, but unfortunately, it isn't quite working out (probably due to script security). Function: def callIdeaInspector() { String[] args = ['-i', '/Applications/Android\\ Studio.app/', '-p', '.idea/inspectionProfiles

How to fix Pipeline-Script “Expected a step” error

戏子无情 提交于 2019-12-11 04:27:18
问题 I am trying to run a simple pipeline-script in jenkins with 2 stages. The Script itself creates a textFile and checks if this one exists. But when i try to run the job i get an "Expected a step" error. the ('Write') stage seems to work perfectly fine so its something with the ('Check') stage. I have read somewhere that you cant have an if inside a step so that might be the or one problem but if so how can i check without using the if? pipeline { agent {label 'Test'} stages { stage('Write') {

Comparison with string doesn't work in Jenkins pipeline

自闭症网瘾萝莉.ら 提交于 2019-12-11 04:06:39
问题 Any idea why the IF-ELSE below works def checkPrValidity() { wordCountStr = sh returnStdout: true, script: 'git diff --ignore-space-at-eol $target_branch..PRbranch src | wc -l' wordCount = wordCountStr.toInteger() //force conversion to int data type if (wordCount == 0) { return false; } else { println("This is a valid PR, continue the job execution") return true; } } while the one below doesn't def checkPrValidity() { wordCountStr = sh returnStdout: true, script: 'git diff --ignore-space-at

Change groovy variables inside shell executor in Jenkins pipeline

人盡茶涼 提交于 2019-12-11 03:34:37
问题 I have a Jenkins pipeline job where I am taking some build variables as input, and if the variables are not passed by the user, I execute a script and get the value of those variables. Later I have to use the value of these variables to trigger other jobs. So my code looks something like this: node { withCredentials([[$class: 'StringBinding', credentialsId: 'DOCKER_HOST', variable: 'DOCKER_HOST']]) { env.T_RELEASE_VERSION = T_RELEASE_VERSION env.C_RELEASE_VERSION = C_RELEASE_VERSION env.N