jenkins-pipeline

Basic Auth with Jenkins http-request-plugin

北战南征 提交于 2019-11-30 20:19:34
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.content}" } results in java.lang.IllegalStateException: Authentication 'user:pass' doesn't exist anymore

How can I block a Jenkins 2.x Pipeline job while dependent jobs are building

你。 提交于 2019-11-30 20:06:19
My question is fairly straightforward: With a Freestyle Jenkins project under "Advance Project Options" I can select two configuration options that help prevent conflicts between different projects (that may arise e.g. when one project updates a set of header files while another project is including these): Block build when upstream project is building Block build when downstream project is building For a Pipeline or Multibranch project these configuration options are unavailable, and I am (so far without success) looking for a way to achieve the same effect for a Pipeline or Multibranch

Is it possible to disable [Pipeline] messages in Jenkins pipeline console output?

☆樱花仙子☆ 提交于 2019-11-30 19:44:57
I am working on some particular Jenkins pipeline which has many steps included - most of which are written in Groovy - because of that I am seeing many [Pipeline] messages which are totally unimportant and unnecessary for me. Is it possible to suppress those? I am asking for something similiar as in related question 2. but I would like to supress all [Pipeline] messages - which includes messages like: [Pipeline] node [Pipeline] { [Pipeline] stage [Pipeline] { (Test) [Pipeline] bat [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline And more... Related

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

南笙酒味 提交于 2019-11-30 17:42:19
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, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, getContext, git, input, isUnix,

Jenkins Pipeline Plugin pass build Job parameters between jobs started in a pipeline

烈酒焚心 提交于 2019-11-30 17:20:19
问题 Would be grateful for a decent full code example of how to pass parameters (parameterized build) from JobA to JobB in Jenkins Pipeline plugin? I am using a script like below and can not figure from the docs how to access parameters from JobA in say a build step shell script in JobB : build job: 'JobA', parameters: [[$class: 'StringParameterValue', name: 'CVS_TAG', value: 'test']] build job: 'JobB', parameters: [[$class: 'StringParameterValue', name: 'CVS_TAG', value: 'test']] echo env.CVS_TAG

How to retrieve current workspace using Jenkins Pipeline Groovy script?

风流意气都作罢 提交于 2019-11-30 16:26:27
问题 I am trying to get the current workspace of my Jenkins build using a Groovy pipeline script: node('master') { // PULL IN ENVIRONMENT VARIABLES // Jenkins makes these variables available for each job it runs def buildNumber = env.BUILD_NUMBER def workspace = env.WORKSPACE def buildUrl = env.BUILD_URL // PRINT ENVIRONMENT TO JOB echo "workspace directory is ${workspace}" echo "build URL is ${env.BUILD_URL}" } It returns: [Pipeline] Allocate node : Start Running on master in /Users/Shared

How to determine the current operating system in a Jenkins pipeline

人走茶凉 提交于 2019-11-30 15:15:37
What would be the way to determine the current OS a Jenkins pipeline is running? Context: I'm building a shared Jenkins pipeline script that should run on all platforms (windows, OSX, linux) and execute something different in each platform. I tried something like: import org.apache.commons.lang.SystemUtils if (SystemUtils.IS_OS_WINDOWS){ bat("Command") } if (SystemUtils.IS_OS_MAC){ sh("Command") } if (SystemUtils.IS_OS_LINUX){ sh("Command") } But even it is running on windows or mac node it always goes into the SystemUtils.IS_OS_LINUX branch I tried a quick pipeline like this. node('windows ')

How to set specific workspace folder for jenkins multibranch pipeline projects

吃可爱长大的小学妹 提交于 2019-11-30 15:07:34
问题 I have an external tool that should be called as build-step in one of my jenkins jobs. Unfortunately, this tool has some issues with quoting commands to avoid problems with whitespaces in the path that is called from. Jenkins is installed in C:\Program Files (x86)\Jenkins . Hence I'm having trouble with jenkins calling the external tool. What I tried is to set "Workspace Root Directory" in Jenkins->configuration to C:\jenkins_workspace in order to avoid any whitespaces. This works for

Error: The parallel step can only be used as the only top-level step

别说谁变了你拦得住时间么 提交于 2019-11-30 13:54:39
When I use this script it works as expected: stage("B") { parallel ( 'C' : { stage ("BC") { parallel ( 'E' : { stage("Many") { println "E1" println "E2" } }, 'F' : { println "F" } ) } }, 'D' : { println "D" } ) } But if enclosed in a pipeline block it fails with an Error "Invalid step 'stage' used - not allowed in this context - The stage step cannot be used in step blocks in Pipeline" pipeline { agent label:"debian" stages { stage("B") { parallel ( 'C' : { stage ("BC") { parallel ( 'E' : { stage("Many") { println "E1" println "E2" } }, 'F' : { println "F" } ) } }, 'D' : { println "D" } ) } }

How to attach files to Jenkins Pipeline notification

为君一笑 提交于 2019-11-30 13:46:55
I am trying in a pipeline to attach files to my notification mails. How can I do that? An example would be nice. email-ext uses Ant File Syntax As for example usage: emailext attachmentsPattern: '**/report.html', body: 'Find attachments', subject: 'test', to: 'test@me.org' 来源: https://stackoverflow.com/questions/41422526/how-to-attach-files-to-jenkins-pipeline-notification