jenkins-pipeline

Hiding passwords in Jenkins Pipeline log output without using WithCredentials

﹥>﹥吖頭↗ 提交于 2019-12-10 17:34:38
问题 I have a parametrized Jenkins pipeline based on a Jenkinsfile . Some of the parameters contain sensitive passwords that I don't want to appear in the job's build logs. So my question is: can I somehow register a String within the Jenkinsfile that is then replaced - by let's say ********** - whenever it appears in the log output? I am aware of the withCredentials step, but I can't use it, since the credentials are not stored in the Jenkins credentials store (but provided as parameters at

Pick JenkinsFile from custom location in pipeline plugin of jenkins

女生的网名这么多〃 提交于 2019-12-10 16:44:52
问题 Can jenkins pipeline plugin pick jenkinsfile from a custom location and start the build? i don't want to keep jenkinsfile inside the source code. If there is any change in the source code. jenkinsfile from custom location should be picked and build should be started. Example:/home/test/jenkinsfile 回答1: You can of-course just try to put a custom location (I wouldn't see why it can't) as long as the user has rights to read the location. If it is a multibranch pipeline, than no. Because indexing

Jenkins get user who aborted a build

别等时光非礼了梦想. 提交于 2019-12-10 16:18:30
问题 Is there a way to get the username when a build is aborted by a user? Preferably using jenkins pipeline code. When a build is aborted by a user, it logs: Aborted by <username> so I hope it is stored as a variable for a brief period. Use case: username to be later used to inform the user itself or other users via email or other means of messaging. 回答1: It seems that a InterruptedBuildAction object is inserted in to the list of build action if a job is aborted. This object can be used to

Jenkins Pipeline: Shouldn't closures resolve variables the same inside parallel as outside?

大城市里の小女人 提交于 2019-12-10 16:06:55
问题 I'm experiencing some confusing behavior trying to execute code in a Jenkins pipeline script. Values inside a closure take on some unexpected values. I've seen references to a local variable trick that supposedly fixes this, but it is not working for me. Simplified example: Create 3 jobs 'a', 'b', 'c' that print their argument - as passed in and as copied to a local. First execute the jobs in parallel; then execute outside parallel to compare the result. "say" is defined because println gives

Did not schedule build for branch

穿精又带淫゛_ 提交于 2019-12-10 15:01:08
问题 I am just starting with jenkins. And I am trying to run a build on a branch/master. And all I am getting is Did not schedule build for branch: master Here is the log: Started by timer [Sun Mar 05 18:23:43 NPT 2017] Starting branch indexing... Connecting to https://bitbucket.org using sameerkattel@hotmail.com/****** (sameer_kattel) Repository type: Git Looking up sameer_kattel/protected-consumer for branches Checking branch single_page_app from sameer_kattel/protected-consumer Checking branch

Grant copy artIfact permission in multi-branch pipeline

落花浮王杯 提交于 2019-12-10 14:57:42
问题 I have the following setup: A Jenkins multi-branch pipeline job configured through Jenkinsfile . After successful checkout and build, the artifact is archived and a downstream job is triggered to deploy the generated artifact. For the second job to be able to copy the artefact through the [$class: 'CopyArtifact'... step, it needs copy permissions. So the question is, how do I grant those permissions through the Jenkinsfile of the upstream job? 回答1: For Scripted Pipeline Syntax, this works:

Jenkins Amazon ECR: no basic auth credentials

本秂侑毒 提交于 2019-12-10 14:51:11
问题 I'm not able to push ocker images to Amazon ECR with Jenkins Pipeline: I always get no basic auth credentials :-( Here is my setup: Jenkins 2.46.2 Amazon ECR plugin 1.4 I've added AWS credentials aws-jenkins to Jenkins (tested locally and successfully pushed to AWS ECR) I've printed /root/.dockercfg to debug auth in my Jenkinsfile Jenkinsfile: stage("Docker") { dir(path) { docker.build("my-image:latest") } docker.withRegistry("https://<my-aws-id>.dkr.ecr.eu-central-1.amazonaws.com", "ecr:eu

How to put jobs inside a folder in jenkins?

雨燕双飞 提交于 2019-12-10 14:36:23
问题 I'm trying to put jobs inside a folder using jenkins DSL script Now i create a listView and i put inside my jobs here the code i'm using listView('MyJobsList') { jobs { map.each{ name((it.key).trim()) } } columns{ status() weather() name() lastSuccess() lastFailure() lastDuration() buildButton() } } i want to do the same thing but this time i want to put the jobs in a folder !! 回答1: Please refer the below Job-DSL documentation to create a folder in Jenkins through Job-DSL. Folder folder(

Clean way to exit declarative Jenkins pipeline as success?

∥☆過路亽.° 提交于 2019-12-10 13:53:33
问题 I am looking for the cleanest way to exit a declarative Jenkins pipeline, with a success status. While exiting with an error is very neat using error step , I couldn't find any equal way to exit with success code. E.G: stage('Should Continue?') { when { expression {skipBuild == true } } steps { echo ("Skiped Build") setBuildStatus("Build complete", "SUCCESS"); // here how can I abort with sucess code? // Error Would have been: // error("Error Message") } } stage('Build') { steps { echo "my

Check a plugin exists within a Jenkins Pipeline (Groovy)

大城市里の小女人 提交于 2019-12-10 13:38:46
问题 I want to use the Slack Notification Plugin in my pipelines, which is very easy: slackSend color: 'danger', message: 'Everything broke' However, I don't want the build to break if slackSend doesn't exist. Is there a way to check that first? 回答1: You might be able to wrap it in a conditional, though I'm not sure how Jenkins adds stuff to the scripts... if(this.respondsTo('slackSend')) { slackSend color: 'danger', message: 'Everything broke' } 回答2: You could always use the old try/catch to make