jenkins-job-dsl

Can a single seed job process DSLs from multiple repos?

不羁岁月 提交于 2019-12-05 09:57:35
I recently managed to convert several manually-created jobs to DSL scripts (inlined into temporary 'seed' jobs), and was pleasantly surprised how straightforward it was. Now I'd like to get rid of the multiple seed jobs and try to structure things more cleanly. To that end, I created a new jenkins-ci repo and committed all the Groovy DSL scripts to it. Then I created a job-generator Jenkins job that pulls from the jenkins-ci repo and has a single Process Job DSLs step. This step has the Look on Filesystem box ticked, with the DSL Scripts field set to jobs/*.groovy . With global push

Can a Job DSL script be tested

流过昼夜 提交于 2019-12-05 01:47:36
问题 Ideally I'd like to be able to invoke the script with some kind of unit test before I have it execute on a Jenkins. Is there any way to test a Job DSL script other than having jenkins run it? 回答1: Besides the examples in job-dsl-gradle-example, you can also go a step further and write tests for individual files or jobs. For example let's assume you have a job configuration file located in jobs/deployJob.groovy import javaposse.jobdsl.dsl.DslScriptLoader import javaposse.jobdsl.dsl

Start jenkins job immediately after creation by seed job

烂漫一生 提交于 2019-12-05 00:15:56
I'm using the Jenkins DSL plugin to automatically create build jobs for all branches of a git project. The DSL plugin is triggered by web hooks so that it is run immediately after a new branch was created. The generated build jobs for each branch are also configured to be triggered by web hooks. The problem with the current setup is, that the build will only be executed after the second commit. The first commit will trigger the Jenkins DSL plugin to create the respective Jenkins Job and the second commit will then trigger the newly created job. Is there any way, to start a Jenkins job

Groovy script fails to call Slack notification parameter from Jenkins DSL job

坚强是说给别人听的谎言 提交于 2019-12-04 16:36:57
I'm attempting to use the Jenkins Job DSL plugin for the first time to create some basic job "templates" before getting into more complex stuff. Jenkins is running on a Windows 2012 server. The Jenkins version is 1.650 and we are using the Job DSL plugin version 1.51. Ideally what I would like is for the seed job to be parameterised so that when it is being run the user can enter four things: the Job DSL script location, the name of the generated job, a Slack channel for failure notifications, and an email address for failure notifications. The first two are fine: I can call the parameters in

How can I set the job timeout using the Jenkins DSL

廉价感情. 提交于 2019-12-04 06:52:32
How can I use the Jenkins DSL to set the job timeout to 10 minutes ? From http://job-dsl.herokuapp.com/ , I can enter job { name 'ci' description 'Build and test the app.' wrappers { timeout() } } and it generates the following block for the timeout, with a default of 3 minutes. <buildWrappers> <hudson.plugins.build__timeout.BuildTimeoutWrapper> <strategy class='hudson.plugins.build_timeout.impl.AbsoluteTimeOutStrategy'> <timeoutMinutes>3</timeoutMinutes> </strategy> <operationList></operationList> </hudson.plugins.build__timeout.BuildTimeoutWrapper> </buildWrappers> What do I need to enter as

Can a Job DSL script be tested

自古美人都是妖i 提交于 2019-12-03 17:20:53
Ideally I'd like to be able to invoke the script with some kind of unit test before I have it execute on a Jenkins. Is there any way to test a Job DSL script other than having jenkins run it? crasp Besides the examples in job-dsl-gradle-example , you can also go a step further and write tests for individual files or jobs. For example let's assume you have a job configuration file located in jobs/deployJob.groovy import javaposse.jobdsl.dsl.DslScriptLoader import javaposse.jobdsl.dsl.MemoryJobManagement import javaposse.jobdsl.dsl.ScriptRequest import spock.lang.Specification class

Job DSL Plugin Vs Pipeline Plugin

烈酒焚心 提交于 2019-12-03 00:47:30
问题 What is the major difference between Job DSL Plugin and Pipeline Plugin both provide way to programmatic job creation which is the best to use as moving ahead and why? if both have similar functionality, do they have different use cases? Since Jenkins 2.0 is focusing on Pipelines as code, does this mean that job-dsl does not have a future or Pipeline Plugin is the next step in the Job DSL Plugin? 回答1: I have extensive experience with both. A concise reply is that Job DSL has existed for much

How to refactor common Jenkins JobDSL code?

谁都会走 提交于 2019-12-02 18:08:28
I have the following JobDSL spec: job { steps { gradle('generateLock saveLock', '-PdependencyLock.includeTransitives=true', true) { node -> node / wrapperScript('${NEBULA_HOME}/gradlew') } gradle('check', '', true) { node -> node / wrapperScript('${NEBULA_HOME}/gradlew') } } } I'd like to refactor the common code, say, into a function: def gradlew(String tasks, String options) { gradle(tasks, options, true) { node -> node / wrapperScript('${NEBULA_HOME}/gradlew') } } But the gradle function isn't visible from within the gradlew function. What's the right way to do this? daspilker The curly

Job DSL Plugin Vs Pipeline Plugin

房东的猫 提交于 2019-12-02 14:13:50
What is the major difference between Job DSL Plugin and Pipeline Plugin both provide way to programmatic job creation which is the best to use as moving ahead and why? if both have similar functionality, do they have different use cases? Since Jenkins 2.0 is focusing on Pipelines as code, does this mean that job-dsl does not have a future or Pipeline Plugin is the next step in the Job DSL Plugin? I have extensive experience with both. A concise reply is that Job DSL has existed for much longer and was Netflix's open source solution for "coding" Jenkins. It allowed you to introduce logic and

How do I run a Jenkins job where user can enter a date value?

微笑、不失礼 提交于 2019-12-02 04:33:31
问题 I wanted to run a jenkins job by accepting a date field (in format YYYY-MM-DD) from user. I found a link where user can enter a string parameter: job('example') { parameters { stringParam('myParameterName', 'my default stringParam value', 'my description') } } But in string param user can enter any thing. So how do I force user to enter a date field like a calender field and select date from the calender ? 回答1: There seems to be no plugin which provides a date chooser. But you can use the