jenkins-workflow

How to make SCM polling work with the Jenkins Workflow plugin

冷暖自知 提交于 2019-12-31 19:21:07
问题 In a normal freestyle project, I configure the SCM plugin to point to the Git repo that I want to release, and I enable the "Poll SCM" option, which allows me to configure a Stash webhook to tell Jenkins whenever there has been a change to that repo. In this way, the job can be triggered whenever a change is pushed to the repo. But when I use a workflow instead of a freestyle project, the SCM of the code that I need to build is specified programmatically in the groovy workflow script, which

Jenkins Pipeline Plugin: execute shell and parse output

亡梦爱人 提交于 2019-12-30 17:04:39
问题 I am using the Jenkins Pipeline plugin to execute an iOS Checkout-Build-Test-Deploy pipeline. One step involves checking whether an iDevice is actually connected (otherwise the rest of the steps will not be executed). I want to execute a shell command idevice_id -l (from libimobiledevice) which will print out the device ID of the connected device, or fail if nothing connected. So the steps as I envision them, would be: Execute command sh "/usr/local/bin/idevice_id -l" parse the output somehow

Sandbox is preventing me from formatting a string

一世执手 提交于 2019-12-30 09:56:13
问题 I have a simple groovy script: node ("master") { echo "I am about to try to use String.format" def jjj = String.format("bob") echo jjj } If I put this script right into my job configuration and run it, it runs fine. But if I put that script into a file which I then load via "Workflow script from SCM", I get the error org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified staticMethod java.lang.String format java.lang.String How do I work around this? Is it possible

Can I restrict poll SCM job to be run only once in a day?

北战南征 提交于 2019-12-25 06:49:58
问题 I have a poll SCM job , which polls every 5 minutes for a change in Perforce. But I need the job to be triggered only when first edit happens for the files in perforce in a day. Can I restrict poll SCM job to be run only once in a day? 回答1: Jenkins itself does not provide this kind of behaviour ("run only for the very first change every day"). You need to split this down into two parts; the first one polling SCM, the second taking care that the job will not run more than once per day.

How do we access Jenkins workflow input parameter values?

纵饮孤独 提交于 2019-12-24 13:13:03
问题 Presumably the parameters that are specified in a Jenkins workflow input step are available for consumption and conditional logic? How do we obtain those values? e.g. how do we obtain and reference true or false value for the checkbox parameter in the following: input id: 'Proceed1', message: 'Proceed or abort?', parameters: [[$class: 'BooleanParameterDefinition', defaultValue: false, description: '', name: 'Please confirm you agree with this']] 回答1: The return value of the input step will be

Iterating a groovy list in Jenkins Pipeline DSL

人走茶凉 提交于 2019-12-23 18:30:03
问题 I have a simple groovy list in my Pipeline that adds some maps: def componentList = [] def componentMapEntry1 = [:] componentMapEntry1['componentName']="Dashboard_Core" componentList << componentMapEntry1 def componentMapEntry2 = [:] componentMapEntry2['componentName']="Dashboard_Equities" componentList << componentMapEntry2 def cme3 = [:] cme3["componentName"] = "home" componentList << cme3 When job is executed, I validate size echo "size of list "+componentList.size() ... [Pipeline] echo

How to use SSH keys with Jenkins Workflow Plugin

旧巷老猫 提交于 2019-12-23 17:07:59
问题 Have a groovy script that's executed by the Jenkins Worflow Plugin. As documented, the git step has only basic configuration so far, having only a single url parameter, and it's suggested to use the general checkout scm step for anything more complex. With this, it's possible to pass credentialsId as so: checkout scm: [$class: 'MercurialSCM', source: 'ssh://hg@bitbucket.org/user/repo', clean: true, credentialsId: '1234-5678-abcd'] But how would one get this to work with an SSH key credentials

Jenkins Build Flow versus Workflow (Pipeline) plugin

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 07:46:04
问题 I notice there are (at least) two orchestration options for Jenkins Build Flow Workflow - Now known as Pipeline I found Build Flow first and implemented an orchestration job around that which seems to work OK for our needs. Are there any advantages to switching to Pipeline? My thoughts for switching to Pipeline are Pro - The project seems more active than Build Flow Con - The DSL seems much more complex 回答1: Pipeline / Workflow is based off concepts from the Build Flow plugin. Based on the

Jenkins Pipelines: Re-use workspace when loading an external Jenkins pipeline script

我只是一个虾纸丫 提交于 2019-12-22 09:59:50
问题 I have the following use case: Checkout/pull a certain Git revision, using written pipeline script (I need this because I retrieve the revision dynamically) From that revision, load a Jenkins-pipeline-file, located among the previously checked out files This file would rely on files from the same checked out revision (thus, from the same workspace) Problem: The loaded Jenkins-pipeline-file gets executed in a new workspace. But it is empty. I need that file to get executed in the same old

Docker Plugin for Jenkins error: Scripts not permitted to use method

会有一股神秘感。 提交于 2019-12-22 08:41:39
问题 I'm trying to publish to Docker from my Jenkins Pipeline but most things I try result in an error. My latest try was this: docker.withDockerRegistry('https://docker-registry.myco.com/lsacco/swagger-rest', 'docker-credential') { def image = docker.image(APPLICATION_NAME); image.tag("latest"); image.push() } When I run this, Jenkins outputs this error: org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod