jenkins-pipeline

How can I reference the Jenkinsfile directory, with Pipeline?

喜夏-厌秋 提交于 2019-12-03 08:14:28
问题 I have a groovy file, I want to run from the Jenkinsfile. ie. load script.groovy However, I am not sure how I can reference this file if it is stored in the same directory as the Jenkinsfile. I am loading the Jenkinsfile from git. I noticed it creates a folder called workspace@script . It does not place this in the workspace directory. I could hardcode the folder but I am not sure the rules on this and it seems a little redundant to check-out the code again. java.io.FileNotFoundException:

Limiting Jenkins pipeline to running only on specific nodes

你。 提交于 2019-12-03 08:08:46
问题 I'm building jobs that will be using Jenkins piplines extensively. Our nodes are designated per project by their tags, but unlike regular jobs the pipeline build does not seem to have the "Restrict where this project can be run" checkbox. How can I specify on which node the pipeline will run the way I do for regular jobs? 回答1: You specify the desired node or tag when you do the node step: node('specialSlave') { // Will run on the slave with name or tag specialSlave } See https://jenkins.io

Cant open Blue Ocean visual pipeline editor

微笑、不失礼 提交于 2019-12-03 08:03:58
Recently I installed Blue Ocean plugin, but I can't find out how to edit or create pipeline using plugin's UI. When I create new pipeline in Blue Ocean and connect with GitLab repo, I don't have option to create/edit pipeline (Jenkinsfile file). No matter if repo contains it or not. When Ocean connects to git server creation is over. I cannot open visual pipeline editor via URL ([local-address]/blue/organizations/jenkins/pipeline-editor/[project-name]). I get error alert with message: Error loading Pipeline There was an error loading the pipeline from the Jenkinsfile in this repository.

Load Jenkins Pipeline Shared Library from same repository

喜夏-厌秋 提交于 2019-12-03 07:39:55
问题 TL;DR Is there a way to import code into the Jenkinsfile from the local repository (other than the load step)? Why? I've experienced that for complex builds the Jenkinsfile gets kind of bulky and not very maintainable. Now that the build job is code, it would be wonderful to have the same means as for other code. That is, I would like to divide it into smaller (more maintainable) units and unit test them. What I tried shared libraries: allow for dividing our Jenkins Pipeline logic into

How to run multiple stages on the same node with declarative Jenkins pipeline?

筅森魡賤 提交于 2019-12-03 06:41:46
问题 Goal Run multiple stages of a declarative Jenkins pipeline on the same node. Setup This is just a minimal example to show the problem. There are 2 Windows nodes "windows-slave1" and "windows-slave2" both labeled with the label "windows". NOTE: My real Jenkinsfile cannot use a global agent because there are groups of stages that require to run on different nodes (e.g. Windows vs. Linux). Expected Behaviour Jenkins selects one of the nodes in "Stage 1" based on the label and uses the same node

How to access Junit test counts in Jenkins Pipeline project

风格不统一 提交于 2019-12-03 06:38:48
问题 I have just started with Jenkins My freestyle project used to report JUnit tests results in Slack like this MyJenkinsFreestyle - #79 Unstable after 4 min 59 sec (Open) Test Status: Passed: 2482, Failed: 13, Skipped: 62 Now I have moved the same to pipeline project, and all is good except that Slack notifications do not have Test Status done MyPipelineProject #68 UNSTABLE I understand I have to construct the message to send to Slack, and I have done that above for now. The only issue is how do

Xcode Build Error Jenkins: Your session has expired. Please log in

Deadly 提交于 2019-12-03 06:32:41
I'm trying to build my application using jenkins pipeline using shell command. Below is the command i'm using to build the app. sh 'xcodebuild -workspace projectname.xcworkspace - allowProvisioningUpdates -scheme projectname_UAT -sdk iphoneos - configuration Debug clean build' Below is the error i'm getting i console. note: Using new build system note: Planning build 2018-10-11 11:19:36.638 xcodebuild[92399:5181481] DVTPortal: Service '' encountered an unexpected result code from the portal ('1100') 2018-10-11 11:19:36.638 xcodebuild[92399:5181481] DVTPortal: Error: Error Domain

Get git branch name in Jenkins Pipeline/Jenkinsfile

好久不见. 提交于 2019-12-03 06:29:24
问题 I've create a jenkins pipeline and it is pulling the pipeline script from scm. I set the branch specifier to ' all ', so it builds on any change to any branch. How do I access the branch name causing this build from the Jenkinsfile? Everything I have tried echos out null except sh(returnStdout: true, script: 'git rev-parse --abbrev-ref HEAD').trim() which is always master . 回答1: If you have a jenkinsfile for your pipeline, check if you see at execution time your branch name in your

How to re-use previously created workspace across stages

此生再无相见时 提交于 2019-12-03 05:47:20
问题 I am facing an issue where I have two stages defined in my pipeline that both are run on the same node and need to be run in the same workspace. The first of these stages runs on my master node initially, but towards the end of the steps defined has to unstash some files onto a different node. The second stage then just needs to continue on my master, and relies on some modules that were installed from the first stage. Here is my pipeline to better explain: #!groovy pipeline { agent { label

How to approve script snippets from a jenkinsfile via the groovy script console?

£可爱£侵袭症+ 提交于 2019-12-03 05:45:41
In my jenkins pipeline file I use the JsonSlurperClassic to read build configurations from a .json file. This however introduces code that needs to be approved over the in-process Script Approval page. This works fine when I do it over the GUI. However I also have a script that automatically sets up my jenkins machine which should create a ready-to-work machine that does not require further GUI operations. This script already uses the jenkins script console to approve slave start-up commands. The groovy code that is executed in the script console to do this looks like this. def language =