jenkins-pipeline

Dynamic Parameter in Jenkinsfile?

允我心安 提交于 2019-12-01 14:39:19
问题 How can I use the Jenkins Dynamic Plugin in a Jenkinsfile ? What I am looking for is a Jenkinsfile snippet that: Enables the Build with Parameters option in the Jenkins job When selected, a script that populates a list that can be used Dynamic Choice Parameters is populated and the user will see a drop down list. When trying: Pipeline syntax in the Jenkins editor Selecting properties: Set job properties as Sample step Selecting This project is parameterized Using Dynamic Choice Parameter

Sonar Gerrit plugin not reporting results

☆樱花仙子☆ 提交于 2019-12-01 14:01:33
We utilize the pipeline and after the build completes successfully we are running the following: bat "mvn sonar:sonar -B -s ${buildSettings} -Dsonar.analysis.mode=preview -Dsonar.skipDesign=true -Dsonar.report.export.path=sonar-report.json" sonarToGerrit(severity: 'Major', postScore: true, category: 'Code-Review', newIssuesOnly: true, issuesScore: '0', noIssuesScore: '0', changedLinesOnly: true) The below build log shows that it found a good number of issues but yet the issues to be commented is 0. Build log Other posts suggest that it may not be finding the report but I don't believe it's the

Jenkins trigger on-demand slaves in dockers

好久不见. 提交于 2019-12-01 08:57:07
I'm looking for a way to run Jenkins jobs/build inside Jenkins slaves, dynamically (on-demand) started docker. Attaching schema for visual understanding. What I'm actually looking for and my flow looks like: 1) Triggering Jenkins job (manually/git/gerrit) 2) Jenkins master (running in docker) starts slave machine docker (and pass script/instructions of the build) 3) Build is running on Jenkins slave (or slaves if parallel/pipeline) 4) Result returned to Jenkins master 5) Jenkins slave docker stops Is it possible to do it this way? Docker slave image creation steps like installing openssh, user

Groovy list with variable name containing a dot (.) gets converted to string

老子叫甜甜 提交于 2019-12-01 08:55:16
I have a list in groovy, defined as env.list = ["abc","def"] If I try using this in a for loop for (letters in env.list) { print("Letter is $letters") } It will iterate over each letter and print the following - Letter is [ Letter is " Letter is a ..... If I define the list as follows - list = ["abc","def"] It will treat this as a list. The for loop will print the following. Letter is abc Letter is def Was using groovy to run my Jenkins pipeline. Why is there a difference based on the name? How can we define a list using a variable name with a dot (.)? in jenkins pipeline the env - is a

How to use methods from a global external java library in a Groovy Jenkins Pipeline?

ⅰ亾dé卋堺 提交于 2019-12-01 08:43:50
问题 First, I´m new to Java, Groovy and Jenkins so please be patient with me ;) I´m preparing a Jenkins server with Pipeline support for future use in our build environment. We use a special inhouse scripting language for which i have to write a wrapper in java. There is no option to do the work only in Groovy, we have to use this special language. I have tried many methods of referencing the java lib to this jenkins project but neither worked. Mainly i´ve used the documentation on https://github

Jenkins pipeline poll perforce

雨燕双飞 提交于 2019-12-01 08:20:36
问题 In continuation to jenkins-pipeline-syntax-for-p4sync - I am not able to get the "Poll SCM" option work for my pipeline job. Here is my configuration: "Poll SCM" is checked and set to poll every 10 minutes Pipeline script contains the following: node ('some-node') // not actual value { stage ('checkout') { checkout([ $class: 'PerforceScm', credential: '11111111-1111-1111-1111-11111111111', // not actual value populate: [ $class: 'AutoCleanImpl', delete: true, modtime: false, parallel: [

Jenkins Declarative Pipeline: How to inject properties

不羁的心 提交于 2019-12-01 06:12:15
I have Jenkins 2.19.4 with Pipeline: Declarative Agent API 1.0.1. How does one use readProperties if you cannot define a variable to assign properties read to? For example, to capture SVN revision number, I currently capture it with following in Script style: ``` echo "SVN_REVISION=\$(svn info ${svnUrl}/projects | \ grep Revision | \ sed 's/Revision: //g')" > svnrev.txt ``` def svnProp = readProperties file: 'svnrev.txt' Then I can access using: ${svnProp['SVN_REVISION']} Since it is not legal to def svnProp in Declarative style, how is readProperties used? You can use the script step inside

Triggering Jenkins build on both new tags & commits

北战南征 提交于 2019-12-01 06:07:24
We are using the Git Plugin : https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin Currently, via webhooks we start a Jenkins build whenever a change is pushed to GitHub. Now we want to trigger the same build when a new tag is added. So we have two triggering conditions : A code change is pushed to GitHub A tag is created If we try the fix mention in this thread then the builds start only for tags. jenkins trigger build if new tag is released How can we do it for both scenarios ? Question # 02 : How can we get the tag name inside a Jenkins build, is there any environment variable for it. 4

Jenkins - env: ‘node’: No such file or directory

两盒软妹~` 提交于 2019-12-01 05:56:12
I have a jenkins server that is configured using https://github.com/shierro/jenkins-docker-examples/tree/master/05-aws-ecs I am running a blue ocean pipeline using a simple Jenkinsfile and the jenkins NodeJS plugin pipeline { agent any tools { nodejs 'node10' } stages { stage ('Checkout Code') { steps { checkout scm } } stage ('Install dependencies') { steps { sh "echo $PATH" sh "npm install" } } } } I made sure to add the node10 global tool as well w/c is used above When the pipeline gets to the script sh "npm install" i am running through this error this is the output of the command echo

Groovy list with variable name containing a dot (.) gets converted to string

社会主义新天地 提交于 2019-12-01 05:54:59
问题 I have a list in groovy, defined as env.list = ["abc","def"] If I try using this in a for loop for (letters in env.list) { print("Letter is $letters") } It will iterate over each letter and print the following - Letter is [ Letter is " Letter is a ..... If I define the list as follows - list = ["abc","def"] It will treat this as a list. The for loop will print the following. Letter is abc Letter is def Was using groovy to run my Jenkins pipeline. Why is there a difference based on the name?