jenkins-pipeline

Can a Jenkins pipeline have an optional input step?

痴心易碎 提交于 2019-12-21 12:12:52
问题 Is it possible to create a Jenkins pipeline with an optional input stage? The below snippet doesn't achieve this goal. Expected behaviour The stage (and therefore the input prompt) should only run for specific branches. Actual behaviour This stage runs for all branches. The when filter is ignored when an input step is used. stage('Approve') { when { expression { BRANCH_NAME ==~ /^qa[\w-_]*$/ } } input { message "Approve release?" ok "y" submitter "admin" parameters { string(name: 'IS_APPROVED

How to get username password stored in Jenkins credentials separately in jenkinsfile

落爺英雄遲暮 提交于 2019-12-21 09:14:37
问题 I've stored username and password as credentials in jenkins. Now I would like to use them in my Jenkinsfile. I am using withCredentials DSL, however, I'm not sure how to get the username password as separate variables so I can use them in my command. This is what I'm doing: withCredentials([usernameColonPassword(credentialsId: 'mycreds', variable: 'MYCREDS')]) { sh 'cf login some.awesome.url -u <user> -p password' } How can I the username and passwork separately? I tried doing ${MYCREDS.split

Error: “Expected named arguments” in parallel in Jenkins groovy script

核能气质少年 提交于 2019-12-21 06:58:57
问题 I have a Jenkins 2.0 pipeline, with a groovyscript like this: node('nnh561.raijin') { stage 'checkout' build('trunk/checkout') stage 'build' parallel( { build('trunk/build/gfortran') }, { build('trunk/build/ifort') } ) } Each of the individual jobs builds fine, but when I try to run the pipeline, it spits out this error when it hits the parallel step: java.lang.IllegalArgumentException: Expected named arguments but got [org.jenkinsci.plugins.workflow.cps.CpsClosure2@242d0d3a, org.jenkinsci

Jenkinsfile Active Choice Parameter

做~自己de王妃 提交于 2019-12-21 06:57:43
问题 How can i use this dsl script in Multibranch Pipeline jenkinsfile(declerative)? parameters { activeChoiceParam('States') { description('Select a state option') filterable() choiceType('SINGLE_SELECT') groovyScript { script('["Sao Paulo", "Rio de Janeiro", "Parana:selected", "Acre"]') fallbackScript('return ["ERROR"]') } } activeChoiceReactiveParam('Cities') { description('Active Choices Reactive parameter') filterable() choiceType('CHECKBOX') groovyScript { script(''' if (States.equals('Sao

How to do simple if-statements inside a declarative pipeline in Jenkins

我的梦境 提交于 2019-12-21 06:49:12
问题 I'm trying to convert my Scripted pipeline to a Declarative Pipeline. Wondering how to do a simple if-statement inside a steps {} block. stage ('Deploy to Docker') { steps { parallel ( "instance1" : { environment { containerId = sh(script: "docker ps --quiet --filter name=${fullDockerImageName}", returnStdout: true).trim() } steps { if (containerId.isEmpty()) { docker.image('some/image').run("--name ${fullDockerImageName}") } } } ) } } This causes the following Exception: WorkflowScript: 201:

Deploying An Angular application using continuous integration from git or gitLab

故事扮演 提交于 2019-12-21 05:39:11
问题 I am looking to deploy Angular 5 application with continuous integration from bitbucket on an Apache server Now because I am new to the field, I am unaware of the possible options to do this Like do we need to integrate webpack with Jenkins, or do we need to write some other code on Jenkins, or we can do it without Jenkins and do we need to integrate it along with Sonar Some pages do not give any clue about webpack, while some say you just have to write webpack script in Jenkins Anyone having

GitHub Branch Source Plugin --> only scan for Pull Requests

[亡魂溺海] 提交于 2019-12-21 05:24:06
问题 We use the GitHub Branch Source Plugin in Jenkins. It works great. However it scans both for branches and pull requests. We want to configure the plugin in such way that it only scans for pull requests. Is this possible? If not, where can we post our feature request? 回答1: You can configure this in the job via the checkout behaviors. Just delete the Discover Branches item and it should not find any branches. 来源: https://stackoverflow.com/questions/47438523/github-branch-source-plugin-only-scan

Jenkins Declarative Pipeline with extended choice parameter

不想你离开。 提交于 2019-12-21 05:08:09
问题 I tried out to implement my first Declarative Pipeline with Jenkins to be able to put also the parameter definitions of a job under SCM. I wanted to transfer an existing job that has an extended choice paraemter. Unfortunately I was not able to add it to the parameters{...} section of my script. On the plugin page: https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin I found a comment that stated it should be possible by: import com.cwctravel.hudson.plugins.extended

How can i add Jenkinsfile support to visual studio 2017

非 Y 不嫁゛ 提交于 2019-12-21 03:56:11
问题 I am using Visual Studio 2017 Pro, and i am being driven crazy by the lack of syntax highlighting for the Jenkinsfile in my project. I am using the Declarative Syntax, but i just cant seem to find anything on getting this to work. My research says that its based on groovy, but i dont see a way to map it to that language either. Any help is appreciated. 回答1: This might not be a solution for everyone, but for me, it worked: Jenkinsfiles are the only files without extension I am working with,

Jenkins pipeline code auto trigger with multiple repositories through GitHub Organization Folder Plugin

爱⌒轻易说出口 提交于 2019-12-21 03:35:15
问题 This question is related to the Jenkins job auto trigger with multiple repositories. Defined 3 repo's to checkout in Jenkinsfile. node('slave'){ git clone github.com/owner/abc.git -b ${env.BRANCH_NAME} git clone github.com/owner/def.git -b ${env.BRANCH_NAME} git clone github.com/owner/ghi.git -b ${env.BRANCH_NAME} } Configured Jenkins job using Github organization plugin. In this case my Jenkinsfile is in abc repo and the Jenkins auto trigger is working fine for the abc repo. its not working