Questions tagged [jenkins-job-dsl]

Jenkins Job-DSL is a Jenkins plugin which enables the creation of Jenkins Jobs using Groovy scripts. It's available in the standard Jenkins plugin list.

For command reference see the Job DSL API Viewer.

Example of DSL script:

job('Hello World') {
  description 'A Simple Job'
  scm {
    github 'pdurbin/maven-hello-world'
  }
  steps {
    maven 'package', 'my-app/pom.xml'
  }
  publishers {
    archiveArtifacts 'build/**/jar'
  }
}

Links

844 questions
71
votes
4 answers

Job DSL Plugin Vs Pipeline Plugin

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…
Mr.Pramod Anarase
  • 1,454
  • 2
  • 15
  • 19
43
votes
9 answers

seed job asks for script approval in jenkins

I was trying to execute a seed job(having github url with groovy scripts) in jenkins and got following error. First time build. Skipping changelog. Processing DSL script APIServerDeployer.groovy ERROR: script not yet approved for use …
ricky
  • 471
  • 1
  • 5
  • 11
38
votes
1 answer

Create a file with some content using Groovy in Jenkins pipeline

I am trying to create a file called groovy1.txt with the content "Working with files the Groovy way is easy." Note: I don't want to use the shell to create this file, instead I want to use Groovy to achieve this. I have following script in my…
smc
  • 2,175
  • 3
  • 17
  • 30
34
votes
5 answers

Job DSL to create "Pipeline" type job

I have installed Pipeline Plugin which used to be called as Workflow Plugin earlier. https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Plugin I want to know how can i use Job Dsl to create and configure a job which is of type Pipeline
32
votes
3 answers

How can I export an existing job into an Jenkinsfile?

I would like to use Pipeline to keep track of my Jenkin Jobs within my SCM. (Source control manager). Is there a way I can take my existing jobs and export them to a valid Jenkinsfile which can be read by Pipeline? The main plugins I'm using which I…
Bob
  • 1,605
  • 2
  • 18
  • 33
29
votes
1 answer

How to refactor common Jenkins JobDSL code?

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 -> …
Noel Yap
  • 18,822
  • 21
  • 92
  • 144
28
votes
5 answers

Jenkins JobDSL multibranchPipelineJob change script path

I am trying to create a multibranchPipelineJob in jobDSL, however the Jenkinsfile is at an alternative location to the default. I have looked through the docs https://jenkinsci.github.io/job-dsl-plugin/#path/multibranchPipelineJob and I cannot see…
apr_1985
  • 1,764
  • 2
  • 14
  • 27
18
votes
3 answers

What are seed jobs in Jenkins and how does it work?

What are seed jobs in Jenkins and how does it work ? Can we create a new job from seed job without using github ?
Sreevalsa E
  • 905
  • 5
  • 17
  • 39
17
votes
2 answers

Difference between 'Delete workspace before build starts' and 'Wipe out repository & force clone' in Jenkins?

I am testing the jenkins job-dsl plugin. I have an existing project where the setting 'Delete workspace before build starts' is enabled. I have the following DSL defined: job("$basePath/my-project") { scm { git { remote { …
Wim Deblauwe
  • 25,113
  • 20
  • 133
  • 211
15
votes
2 answers

Using env variables to set other variables in Jenkins pipeline as code

I cannot use environment variables set in previous blocks in access stage below. pipeline{ agent any stages{ stage("set env variable"){ steps{ script{ env.city = "Houston" } } } …
Varunkumar Manohar
  • 887
  • 3
  • 11
  • 29
13
votes
1 answer

Start jenkins job immediately after creation by seed job

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…
Jan Gassen
  • 3,406
  • 2
  • 26
  • 44
12
votes
2 answers

Jenkins task for remote hosts

In deploy scenario i need to create and run jenkins task on list of hosts, i.e. create something like parametrized task (where ip address is a parameter) or a task on Multijob Plugin with HOST axis, but run by only 2 ones in parallel over multiple…
11
votes
3 answers

Multiple cron expressions using the job-dsl/pipeline syntax

In a Jenkins job config's Build Triggers section, it is possible to add multiple cron expressions separated on each line in the Schedule textarea e.g: 13 20 * * 0,1,2,3,4,5,6 13 8 * * 0,1,2,3,4,5,6 https://stackoverflow.com/a/44209349/1291886 How…
edst
  • 1,074
  • 10
  • 20
11
votes
2 answers

How to put jobs inside a folder in jenkins?

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{ …
Ibtissam
  • 509
  • 3
  • 8
  • 21
11
votes
5 answers

How to specify Job DSL checkout timeout in Jenkins Git plugin?

Clone timeout can be specified using: git { ... cloneTimeout(60) } where 60 is timeout is minutes. I read that checkout timeout can also be specified but I cannot find details. Both checkoutTimeout(...) and timeout(...) give an…
Petr Vepřek
  • 1,547
  • 2
  • 24
  • 35
1
2 3
56 57