jenkins-pipeline

Jenkins Pipeline Job with file parameter

∥☆過路亽.° 提交于 2019-11-28 08:13:51
I'm putting together a Jenkins pipeline job which will take a file parameter. I can trigger the job and point it at a file however I can't find where the file has ended up (In an ordinary freestyle job it would be in the workspace). Where has the uploaded file gone? Or do file parameters not currently work with pipelines? There is currently an issue with pipeline and file parameter ( https://issues.jenkins-ci.org/browse/JENKINS-27413 ). Christoph Forster Solved it the following way: node { deleteDir() stage("upload") { def inputFile = input message: 'Upload file', parameters: [file(name: 'data

How do I use Jenkins Pipeline properties step?

会有一股神秘感。 提交于 2019-11-28 07:09:14
I am studying capabilities of Jenkins Pipeline:Multibranch. It is said that a recently introduced properties step might be useful there, but I can't catch how it works and what is its purpose. Its hint message doesn't seem to be very clear: Updates the properties of the job which runs this step. Mainly useful from multibranch workflows, so that Jenkinsfile itself can encode what would otherwise be static job configuration. So I created a new Pipeline with this as a script (pasted directly into Jenkins not in SCM): properties [[$class: 'ParametersDefinitionProperty', parameterDefinitions: [[

How to implement Post-Build stage using Jenkins Pipeline plug-in?

夙愿已清 提交于 2019-11-28 06:10:38
After reading Jenkins tutorial explaining Pipeline plug-in, it seems that plug-in should make it possible to implement Post-Build steps. However documentation is rather limited in regard to specific instructions. For example I wonder how to implement: Run only if build succeeds Run only if build succeeds or is unstable Run regardless of build result Run only if build succeeds stage 'build' ... build ... tests stage 'post-build' ... (Or add -Dmaven.test.failure.ignore=false to the MAVEN_OPTS ) Run only if build succeeds or is unstable stage 'build' ... build try { ... tests } catch { ... }

Git Variables in Jenkins Workflow plugin

99封情书 提交于 2019-11-28 05:17:01
I'd like to access git variables such as GIT_COMMIT and GIT_BRANCH when I have checked out a repository from git further down in the build stream. Currently I find no available variable to access these two parameters. node { git git+ssh://git.com/myproject.git echo "$GIT_COMMIT - $BRANCH_NAME" } Is such variables available and in case, where would I find them. I don't mind if they are available through some groovy variables or wherever, just that I can access them. Maybe I lack the debugging skills in Groovy and this is easy to find, but I just can't find it with my limited skills. Depending

Running stages in parallel with Jenkins workflow / pipeline

孤街醉人 提交于 2019-11-28 04:39:35
Please note: the question is based on the old, now called "scripted" pipeline format. When using "declarative pipelines", parallel blocks can be nested inside of stage blocks (see Parallel stages with Declarative Pipeline 1.2 ). I'm wondering how parallel steps are supposed to work with Jenkins workflow/pipeline plugin, esp. how to mix them with build stages. I know about the general pattern: parallel(firstTask: { // Do some stuff }, secondTask: { // Do some other stuff in parallel }) However, I'd like to run couple of stages in parallel (on the same node, which has multiple executors), so I

Jenkins: Cannot define variable in pipeline stage

若如初见. 提交于 2019-11-28 04:16:14
I'm trying to create a declarative Jenkins pipeline script but having issues with simple variable declaration. Here is my script: pipeline { agent none stages { stage("first") { def foo = "foo" // fails with "WorkflowScript: 5: Expected a step @ line 5, column 13." sh "echo ${foo}" } } } However, I get this error: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 5: Expected a step @ line 5, column 13. def foo = "foo" ^ I'm on Jenkins 2.7.4 and Pipeline 2.4. abayer The Declarative model for Jenkins Pipelines has a restricted subset of syntax that

Jenkins Pipeline: “input” step blocks executor

南笙酒味 提交于 2019-11-28 03:48:38
After going through the pipeline and Jenkinsfile documentation, I am a bit confused on how to create a Stage -> Production pipeline. One way is to use the input step like node() { stage 'Build to Stage' sh '# ...' input 'Deploy to Production' stage 'Build to Production' sh '# ...' } This seems a bit clunky, as this will block an executor all the time until you want to deploy to production. Is there any alternative way of being able to deploy to production, from Jenkins. StephenKing EDIT (Oct 2016): Please see my other answer "Use milestone and lock" below, which includes recently introduced

Pipeline pass parameters to downstream jobs

寵の児 提交于 2019-11-28 03:39:41
I'm using Jenkins v2.1 with the integrated delivery pipeline feature ( https://jenkins.io/solutions/pipeline/ ) to orchestrate two existing builds (build and deploy). In my parameterized build I have 3 user parameters setup, which also needs to be selectable in the pipeline. The pipeline script is as follows: node: { stage 'build' build job: 'build', parameters: [[$class: 'StringParameterValue', name: 'target', value: target], [$class: 'ListSubversionTagsParameterValue', name: 'release', tag: release], [$class: 'BooleanParameterValue', name: 'update_composer', value: update_composer]] stage

Jenkins Pipeline Wipe Out Workspace

本小妞迷上赌 提交于 2019-11-28 03:21:48
We are running Jenkins 2.x and love the new Pipeline plugin. However, with so many branches in a repository, disk space fills up quickly. Is there any plugin that's compatible with Pipeline that I can wipe out the workspace on a successful build? You can use deleteDir() as the last step of the pipeline Jenkinsfile (assuming you didn't change the working directory). Like @gotgenes pointed out with Jenkins Version. 2.74 , the below works, not sure since when, maybe if some one can edit and add the version above cleanWs() With, Jenkins Version 2.16 and the Workspace Cleanup Plugin , that I have,

Git inside docker inside Jenkins pipeline doesnt work

荒凉一梦 提交于 2019-11-28 02:17:08
I am trying to perform some git queries inside a docker container that runs as part of a Jenkins Pipeline. Out side the docker container the sshsgent is working fine and I can access my SCM no problem. Inside the container I am getting host key verification issues. Can anyone help with the mistake I have made? script { sshagent(['e9f7d09a-7b88-4bf7-814c-464f811d9519']) { sh(""" ssh -p 7999 git@bitbucket-eng-gpk1.com whoami """) } docker.withRegistry('https://dockerhub.banana.com', 'banana-dockerhub-credential') { docker.image('banana_release_base').pull() docker.image('banana_release_base')