jenkins-job-dsl

Jenkins DSL script - Test Failure - Found multiple extensions which provide method lastCompleted

最后都变了- 提交于 2019-12-10 11:56:15
问题 Trying to create multijobs in Jenkins with DSL scripting. There are multiple jobs in a phase and I want to create a consolidated report for the multijob from downstream jobs. I am using copy artifact to copy the results of downstream jobs to the multijob's target dir. Using selector - lastCompleted() However I am getting this an error saying multiple extensions providing the method and tests are failing. lastCompleted() is apparently present in copyArtifact and multijob plugins where in this

Groovy: how to call closure in top scope from another closure

﹥>﹥吖頭↗ 提交于 2019-12-10 10:45:11
问题 I'm trying to break up code that makes use of the Jenkins Job DSL plugin into reusable pieces, and I suspect that my question is generic to Groovy and not Jenkins-specific. For example, I want to reuse parts of this block: freeStyleJob() { //generic stuff name "something" description "something else" //custom stuff scm { svn { //etc.... } } } By placing name and description in a utility method (obviously I want to do more than just that in real life). However, I cannot find the proper syntax

Trigger Jenkins tests after commits in git submodules

痴心易碎 提交于 2019-12-08 01:49:12
问题 I have a super project that only aggregates multiple git sumodules. I would like to trigger Jenkins for each change in submodules as well as when super project is updated. /superproject /submodule-a /submodule-b /submodule-c For each submodule I am using Job DSL plugin and works fine except when some modules require others to compile or run tests -- that is one reason to aggregate all other repos in one super project . What should I do for testing individual submodules as well as integration

Create a Job DSL that creates a new job in the same View

大憨熊 提交于 2019-12-07 09:16:54
问题 I'm trying DSL job plugin to create new jobs in Jenkins. Is there a way to specify the view when creating the job? For example, I have a view NewJobsView . I want to create a DSL job called dsl-job and it is creating a new job "dsl-created-job1" DSL like this: job { name 'dsl-created-job1' //view 'NewJobsView' //or view {...} to specify the view } 回答1: What if you do: def myJob=job{name('test1')} def myJob2=job{name('test2')} view { name('view1') jobs{ name(myJob.name) name(myJob2.name) } }

Adding Suppress automatic scm triggering except for named branches in Jenkins Job DSL?

喜欢而已 提交于 2019-12-07 06:04:35
问题 How do I add default Suppress automatic scm triggering except for named branch - development in Job DSL? I tried docs https://jenkinsci.github.io/job-dsl-plugin/#path/multibranchPipelineJob . It doesn't say much. Seems like it is not supported. So I guess my only way is adding custom properties directly to XML via configure block. What I want: <strategy class="jenkins.branch.NamedExceptionsBranchPropertyStrategy"> <defaultProperties class="java.util.Arrays$ArrayList"> <a class="jenkins.branch

I pull the branch with tag in the groovy

这一生的挚爱 提交于 2019-12-06 15:15:25
I want to pull specified branch with tag. So i write job as following job('abc'){ scm{ git('ssh://git@abc.git', 'refs/tags/test-tag1') } } But it does not work. I inputted branch Name or commit into 2nd param, it will pull the specified branch. It can work with tag from the document of [Jenkins Job DSL Plugin]. I want to know why it doesn't work, Or my job is wrong. You just need to specify the tag name. This works for me: job('example'){ scm { git('https://github.com/jenkinsci/job-dsl-plugin.git', 'job-dsl-1.53') } } My guess: sum needs to be scm :) 来源: https://stackoverflow.com/questions

Groovy: how to call closure in top scope from another closure

时间秒杀一切 提交于 2019-12-06 12:42:35
I'm trying to break up code that makes use of the Jenkins Job DSL plugin into reusable pieces, and I suspect that my question is generic to Groovy and not Jenkins-specific. For example, I want to reuse parts of this block: freeStyleJob() { //generic stuff name "something" description "something else" //custom stuff scm { svn { //etc.... } } } By placing name and description in a utility method (obviously I want to do more than just that in real life). However, I cannot find the proper syntax to create a closure for the current scope. Here is how I think it should look: def jobCommonItems() {

Trigger Jenkins tests after commits in git submodules

坚强是说给别人听的谎言 提交于 2019-12-06 09:04:23
I have a super project that only aggregates multiple git sumodules. I would like to trigger Jenkins for each change in submodules as well as when super project is updated. /superproject /submodule-a /submodule-b /submodule-c For each submodule I am using Job DSL plugin and works fine except when some modules require others to compile or run tests -- that is one reason to aggregate all other repos in one super project . What should I do for testing individual submodules as well as integration as part of a super project? betodelrio I think this does not make sense. If git plugin is configured to

Sparse Checkout with Jenkins DSL Plugin?

帅比萌擦擦* 提交于 2019-12-06 08:17:20
Does anyone have a code sample for the correct configure { ... } block needed in the Jenkins DSL plugin to set up a git sparse checkout? It appears as if the config.xml section looks like this: <extensions> <hudson.plugins.git.extensions.impl.CloneOption> <shallow>false</shallow> <reference>/build/jenkins/codebase.git</reference> </hudson.plugins.git.extensions.impl.CloneOption> <hudson.plugins.git.extensions.impl.SparseCheckoutPaths> <sparseCheckoutPaths> <hudson.plugins.git.extensions.impl.SparseCheckoutPath> <path>BillOfMaterials.yml</path> </hudson.plugins.git.extensions.impl

Jenkins job DSL plugin - hidden parameter

你离开我真会死。 提交于 2019-12-06 04:54:08
I am using the Jenkins hidden parameter plugin but I cant find the syntax to write it in DSL like I am doing with other parameters. For example: https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.BuildParametersContext.activeChoiceParam Is there any way to reflect hidden parameter in DSL? Job DSL has no built-in support for the Hidden Parameter plugin, so it's not mentioned in the API viewer. But it's supported by the Automatically Generated DSL : job('example') { parameters { wHideParameterDefinition { name('FOO') defaultValue('bar') description('lorem ipsum') } }