jenkins-pipeline

Basic Auth with Jenkins http-request-plugin

故事扮演 提交于 2019-11-30 04:28:29
问题 I am trying to make a simple POST-request with the "Http Request Plugin". My problem is with getting the credentials to work. I have set a global credential, user:pass . But trying this in my code withCredentials([usernameColonPassword(credentialsId: 'akamai', variable: 'akamai')]) { def response = httpRequest url: requestUrl, contentType: requestContentType, httpMode: requestHttpMode, requestBody: requestContent, authentication: akamai echo "Status: ${response.status}\nContent: ${response

How to view Jenkins workspace on a Pipeline job?

时光毁灭记忆、已成空白 提交于 2019-11-30 04:11:16
How can I view Jenkins workspace on a Pipeline job (it was called workflow job previously)? In a standard Job I could just go to the Job main page and view it by clicking on "Workspace". sam Go to the Jenkins build On the left hand side click the Pipeline steps Then on the right click on the link that says "Allocate node : Start - (x min in block)" On the the left side click the workspace. Done! The image below might help : Check out this link it shows how to get the workspace when you are using jenkins pipeline: https://www.selikoff.net/2016/07/10/workspace-jenkins-pipelines/ Jesse Glick

Triggering Branch Indexing on Multibranch Pipelines (Jenkins/Git)

百般思念 提交于 2019-11-30 03:51:49
问题 I'm trying to automatically trigger 'Branch Indexing' on a Multibranch Pipelines job in Jenkins. At the moment, only one method seems to actually work, which is polling, but I am unable to do that and polling is a bad solution anyway. The plug-in doesn't support 'Trigger builds remotely (e.g., from scripts)' (options are not saved), so I cannot trigger it via a web hook on push etc. I tried creating a 'trigger' freestyle build on the repo but the 'Post-build Actions - Build other projects'

Create JSON strings from Groovy variables in Jenkins Pipeline

这一生的挚爱 提交于 2019-11-30 03:39:23
I have to create this JSON file in Groovy. I have try many things ( JsonOutput.toJson() / JsonSlurper.parseText() ) unsuccessfully. { "attachments":[ { "fallback":"New open task [Urgent]: <http://url_to_task|Test out Slack message attachments>", "pretext":"New open task [Urgent]: <http://url_to_task|Test out Slack message attachments>", "color":"#D00000", "fields":[ { "title":"Notes", "value":"This is much easier than I thought it would be.", "short":false } ] } ] } This is for posting a Jenkins build message to Slack. daggett JSON is a format that uses human-readable text to transmit data

How to suppress source script lines echo in jenkins pipeline console output?

依然范特西╮ 提交于 2019-11-30 03:31:09
问题 I am writing a pipeline job in Jenkins which shows the output console of a downstream job in the pipeline console output. The job is working so far but the output is really hard to read due to all the echo lines added to the output by the pipeline job itself. Started by user john.doe@cdf.com [Pipeline] Allocate node : Start Running on swqa-pr-prod-slave-1 in /srv/jenkins-slave/workspace/UUT Automated Regression - 1.20 [Pipeline] node { [Pipeline] echo [Pipeline] echo /////////////////////////

Continue Jenkins pipeline past failed stage

房东的猫 提交于 2019-11-30 02:54:36
I have a series of stages that perform quick checks. I want to perform them all, even if there are failures. For example: stage('one') { node { sh 'exit 0' } } stage('two') { node { sh 'exit 1' // failure } } stage('three') { node { sh 'exit 0' } } Stage two fails, so by default stage three is not executed. Ordinarily this would be a job for parallel , but I want to display them in the stage view. In the mock up below: Build #4 shows what normally happens. Job two fails so three does not run. I Photoshopped Build #6 to show what I would like to see. Job two fails and is displayed as such, but

How to use post steps with Jenkins pipeline on multiple agents?

穿精又带淫゛_ 提交于 2019-11-30 02:19:56
When using the Jenkins pipeline where each stage runs on a different agent, it is good practice to use agent none at the beginning: pipeline { agent none stages { stage('Checkout') { agent { label 'master' } steps { script { currentBuild.result = 'SUCCESS' } } } stage('Build') { agent { label 'someagent' } steps { bat "exit 1" } } } post { always { step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "test@test.com", sendToIndividuals: true]) } } } But doing this leads to Required context class hudson.FilePath is missing error message when the email should go out: [Pipeline] {

Use ssh credentials in jenkins pipeline with ssh, scp or sftp

空扰寡人 提交于 2019-11-30 02:13:13
I want to use scp/ssh to upload some files to a server. I discover that I need to use certificate-based authentication, but the question is how? Really what I want to do is to use the same sort of credentials I use with git - passworded ssh cert stored in Jenkins. However, I can't work out how to - the snippet generator has no obvious option for that. What do others do? Is there an undocumented feature that would do this? If you install the SSH Agent plugin you can use the ssh-agent pipeline step to run a shell script with an ssh-agent active. The ssh-agent takes a Jenkins credentials ID (a

java.lang.NoSuchMethodError: No such DSL method 'readJSON'

女生的网名这么多〃 提交于 2019-11-30 01:34:29
问题 def data = readJSON text: '{"rel" : {"configVersion": "1.0","manifest" :"'+"${manifestURL}"+'"}}' writeJSON(file: 'C:\\Users\\Public\\json\\config.json', json: data) I am using JSON function in my Jenkins pipeline and getting NoSuchMethodFoundError . I am using Jenkins 2.85. Any idea how to resolve this issue? java.lang.NoSuchMethodError: No such DSL method 'readJSON' found among steps [archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun,

How to lock multiple stages of declarative Jenkins pipeline?

百般思念 提交于 2019-11-30 01:28:23
I want to run multiple stages inside a lock within a declarative Jenkins pipeline: pipeline { agent any stages { lock(resource: 'myResource') { stage('Stage 1') { steps { echo "my first step" } } stage('Stage 2') { steps { echo "my second step" } } } } } I get the following error: Started by user anonymous org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 10: Expected a stage @ line 10, column 9. lock(resource: 'myResource') { ^ WorkflowScript: 10: Stage does not have a name @ line 10, column 9. lock(resource: 'myResource') { ^ WorkflowScript: 10: