jenkins-pipeline

Copy artifact within a jenkins pipeline

£可爱£侵袭症+ 提交于 2019-12-03 14:10:57
问题 I have a Jenkins pipeline job that archives an Artifact in its first phase, I then need to copy that Artifact in another stage of the pipeline build node { stage 'Stage 1 of build' // Run tests, if successful archive the artifact archiveArtifacts artifacts: 'build/test.js', excludes: null stage 'Stage 2 of build' // want to copy artifact from stage 1 of the build step([$class: 'CopyArtifact', filter: 'build/test.js', fingerprintArtifacts: true, flatten: true, projectName: 'echo-develop-js

How do I stop a running container in Jenkinsfile?

a 夏天 提交于 2019-12-03 13:55:59
问题 I have a Jenkinsfile or a Jenkins pipeline which creates a new image and starts a container out of that image. It works well for the first time. But on subsequent runs, I want the previous container to be stopped and removed. My Jenkinsfile is as follows: node { def commit_id stage('Preparation') { checkout scm sh "git rev-parse --short HEAD > .git/commit-id" commit_id = readFile('.git/commit-id').trim() } stage('docker build/push') { docker.withRegistry('https://index.docker.io/v1/',

Using waitForQualityGate in a Jenkins declarative pipeline

浪子不回头ぞ 提交于 2019-12-03 13:53:17
问题 The following SonarQube (6.3) analysis stage in a declarative pipeline in Jenkins 2.50 is failing with this error in the console log: http://pastebin.com/t2ja23vC. More specifically: SonarQube installation defined in this job (SonarGate) does not match any configured installation. Number of installations that can be configured: 1. Update: after changing "SonarQube" to "SonarGate" in the Jenkins settings (under SonarQube servers, so it'll match the Jenkinsfile), I get a different error: http:/

How to use Jenkins Pipeline Folder-Level Shared Library?

ⅰ亾dé卋堺 提交于 2019-12-03 13:40:07
We have few components which is stored in their own git repositories. Specific combination of those components are built and delivered as solutions for different type of deployments/customers. So, we have a pipeline git repository which has multiple Jenkinsfile (with different names - and so the build names). Obviously, there are many things common between these pipelines. I'm aware of Jenkins shared library and it works when they're given their own git repository. But, since my pipelines are already in dedicated git repository, I'm curious to know how to use "Folder-level Shared Libraries"

Jenkins pipeline with parallel

半世苍凉 提交于 2019-12-03 13:34:47
问题 Here is my Jenkins pipeline that i am trying to execute. I am following this tutorial: pipeline { agent any stages { stage('one') { parallel "first" : { echo "hello" }, "second": { echo "world" } } stage('two') { parallel "first" : { echo "hello" }, "second": { echo "world" } } } } But the job fails with following message. org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 4: Unknown stage section "parallel". Starting with version 0.5, steps in a

How to add a post build action in the pipeline in Jenkins

ⅰ亾dé卋堺 提交于 2019-12-03 13:33:39
Below is my pipeline script node(Slave01) { currentBuild.displayName = "${URL_Name}" } stage 'Pt2ctf process' node(Slave01) { build job: 'Pt2ctf_16_7', parameters: [string(name: 'URL_Name', value: "${URL_name}"), string(name: 'Display_Name', value: "${Display_Name}")] } stage 'add_fields' node(Slave01) { build job: 'add_fields_16_7', parameters: [string(name: 'URL_Name', value: "${URL_Name}")] } The above groovy script would trigger multiple builds in sequence. I have another build to be run once the sequence is completed. I don't see any post build option in the pipeline job configuration. Is

Jenkins docker agent in declarative pipeline: file not found

蹲街弑〆低调 提交于 2019-12-03 13:27:38
问题 When trying to execute the example from https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Controlling-your-build-environment: pipeline { agent { docker 'node' } stages { stage("testing 123") { steps { sh 'node --version' } } } } I get the following output: [Pipeline] // stage [Pipeline] stage [Pipeline] { (Declarative: Agent Setup) [Pipeline] sh [XXXXX-ABOESSRH5FV5AM3VLFMZ4UZP722N63WT5EEAE2JPIXC5U5ZTMBYA] Running shell script + docker pull node Using default tag: latest

Jenkins: no tool named MSBuild found

故事扮演 提交于 2019-12-03 13:08:11
问题 Setting up a Pipeline build in Jenkins (Jenkins 2.6), copying the sample script for a git-based build gives: "no tool named MSBuild found". I have set MSBuild Tool in Manage Jenkins -> Global Tool Configuration . I am running pipeline on the slave node. In Slave configuration, I have set MSBuild tool path in Node Properties -> Tool Locations . While build process it is not able to get MSBuild tool path, if i run same source without pipeline (without using Jenkinsfile) it works fine. Please

How can i add Jenkinsfile support to visual studio 2017

偶尔善良 提交于 2019-12-03 13:02:51
I am using Visual Studio 2017 Pro, and i am being driven crazy by the lack of syntax highlighting for the Jenkinsfile in my project. I am using the Declarative Syntax, but i just cant seem to find anything on getting this to work. My research says that its based on groovy, but i dont see a way to map it to that language either. Any help is appreciated. This might not be a solution for everyone, but for me, it worked: Jenkinsfiles are the only files without extension I am working with, therefore I opened Tools -> Options -> Text Editor -> File Extensions and then, I checked "Map extensionless

How to check if build parameter is available in Jenkinsfile

别等时光非礼了梦想. 提交于 2019-12-03 12:49:21
I have a pipeline script that should work with and without parameters. So I have to check if the parameter is available. I tried if(getBinding().hasVariable("myparameter")) but this leads to an Exception org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.lang.Binding getVariables Is there another way to check if the job is parameterized? Newer versions make the parameters available through the params variable. If the parameter is not defined, it falls back to the configured default (see also here ). In the latest version of jenkins