jenkins-pipeline

Jenkins pipeline with parallel

一笑奈何 提交于 2019-12-03 03:51:30
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 stage must be in a steps block. @ line 4, column 9. stage('one') { ^ WorkflowScript: 12: Unknown stage

Create resusable jenkins pipeline script

狂风中的少年 提交于 2019-12-03 03:40:06
问题 I am considering to use Jenkins pipeline script recently, one question is that I don't figure out a smart to way to create internal reusable utils code, imagine, I have a common function helloworld which will be used by lots of pipeline jobs, so I hope to create a utils.jar can injected it into the job classpath. I notice Jenkins have a similar concept with the global library, but my concern regarding this plugin: Since it is a plugin, so we need to install/upgrade it through jenkins plugin

Jenkinsfile and different strategies for branches

无人久伴 提交于 2019-12-03 03:34:11
问题 I'm trying to use Jenkins file for all our builds in Jenkins, and I have following problem. We basically have 3 kind of builds: pull-request build - it will be merged to master after code review, and if build works manual pull-request build - a build that does the same as above, but can be triggered manually by the user (e.g. in case we have some unstable test) an initial continuous deliver pipeline - this will build the code, deploy to repository, install artifacts from repository on the

How to react on SonarQube Quality Gate within Jenkins Pipeline

我只是一个虾纸丫 提交于 2019-12-03 03:18:55
Within my Jenkins Pipeline I need to react on the SonarQube Quality Gate. Is there an easier way to achieve this but looking in the Sonar-Scanner log for the result page (e.g. https://mysonarserver/sonar/api/ce/task?id=xxxx ) and parse the JSON Result from there? I use Jenkins 2.30 and SonarQube 5.3 Thanks in advance Based on Vincent's answer, and using Pipeline utility steps , here's my updated version that worked for me (using sonarscanner report file) : withSonarQubeEnv('SONAR 6.4') { sh "${scannerHome}/bin/sonar-scanner" sh "cat .scannerwork/report-task.txt" def props = readProperties file

Jenkins: no tool named MSBuild found

故事扮演 提交于 2019-12-03 03:18:32
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 see Jenkinsfile Syntax pipeline { agent { label 'win-slave-node' } stages { stage('build') { steps { bat

Is there a way to run a pre-checkout step in declarative Jenkins pipelines?

喜夏-厌秋 提交于 2019-12-03 03:11:18
Jenkins declarative pipelines offer a post directive to execute code after the stages have finished. Is there a similar thing to run code before the stages are running, and most importantly, before the SCM checkout? For example something along the lines of: pre { always { rm -rf ./* } } This would then clean the workspace of my build before the source code is checked out. pre is a cool feature idea, but doesn't exist yet. skipDefaultCheckout and checkout scm (which is the same as the default checkout) are the keys: pipeline { agent { label 'docker' } options { skipDefaultCheckout true } stages

Executing code when a branch is removed in Jenkins' multi branch pipeline

♀尐吖头ヾ 提交于 2019-12-03 03:03:13
I have a Jenkins that uses multi branch project . That is, when a new branch is created to repository, Jenkins automatically will automatically create a new job for the branch, and remove that job when the branch is removed. Now, I'd like to run some code when the branch is removed, to clear testing environments that were created when the branch was created. It there a way to do this? Not without writing plugin code I think. If you are interested, the relevant extension point would be OrphanedItemStrategy from the cloudbees-folder plugin. 来源: https://stackoverflow.com/questions/37701289

Unknown stage section “withSonarQubeEnv”

百般思念 提交于 2019-12-03 03:00:34
I am experimenting using Pipeline jobs with the Blue Ocean beta plugin enabled on our Jenkins server. We have a sonarqube scanner build step configured in one of our freestyle jobs, which I now want to add a stage for in my Jenkins file. I see from the sonar docs there is a way to achieve this here We are using Jenkins 2.32.3 and have SonarQube scanner 2.8 installed. I tried the suggested stage config block, where our scanner is named 'SonarQube Scanner' stage('SonarQube analysis') { // requires SonarQube Scanner 2.8+ def scannerHome = tool 'SonarQube Scanner 2.8'; withSonarQubeEnv('SonarQube

Conditional step/stage in Jenkins pipeline

微笑、不失礼 提交于 2019-12-03 02:59:15
问题 How do you run a build step/stage only if building a specific branch? For example, run a deployment step only if the branch is called deployment , leaving everything else the same. 回答1: Doing the same in declarative pipeline syntax, below are few examples: stage('master-branch-stuff'){ agent any when{ branch 'master' } steps { echo 'run this stage - ony if the branch = master branch' } } stage('feature-branch-stuff') { agent label:'test-node' when { branch "feature/*" } steps { echo 'run this

Jenkins docker agent in declarative pipeline: file not found

匆匆过客 提交于 2019-12-03 02:52:55
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 latest: Pulling from library/node Digest: sha256