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
10
votes
3 answers

How to load AWS credentials in Jenkins job DSL?

I have the following DSL structure: freeStyleJob { wrappers { credentialsBinding { [ $class:"AmazonWebServicesCredentialsBinding", accessKeyVariable: "AWS_ACCESS_KEY_ID", credentialsId: "your-credential-id", …
8
votes
1 answer

Invoke Job DSL from Jenkins Pipeline

I need to trigger Jenkins Job DSL from pipeline (specifically, i need to mimic 'read definition file from workspace' behavior), but the job dsl plugin isn't yet on pipeline steps list. How can i achieve that?
Etki
  • 2,042
  • 2
  • 17
  • 40
8
votes
4 answers

Trigger build in Jenkins when git branches are created or deleted

I have a job in Jenkins for a project on GitHub, that I would like to be triggered whenever a new branch is created or an existing branch has been removed. Is this possible? Notice: The Jenkins server is located internally in a company, so we can't…
Tobias
  • 1,938
  • 16
  • 12
7
votes
3 answers

How can I use Jenkins Sidebar Link Plugin in pipeline step?

I'm working on this plugin https://plugins.jenkins.io/sidebar-link/ to add a link in jenkins side bar. This plugin works with jenkins project configuration. Now I'm trying to add a pipeline step to call this plugin. I already try lines of code below…
7
votes
2 answers

Exit code to set build unstable - Jenkins DSL Scripting

I am trying to utilize Exit code to set build unstable in job -> publishers -> postBuildScripts -> steps -> shell -> advance option to set my build unstable based on a condition. I have the script below. ... postBuildScripts { …
Siddarth
  • 351
  • 2
  • 6
  • 20
7
votes
2 answers

How to call functions in one Jenkins Shared Library from another

I have two separate libraries (Library A and Library B), I have defined them on the jenkins configuration so they can be both called from the pipeline. From Library A I would like to call some functions/methods that are defined in Library B. My…
ximbal
  • 3,178
  • 2
  • 17
  • 19
7
votes
1 answer

How does DSL extension in Jenkins plugin work

I want to create DSL extension for my Jenkins plugin (built using maven) just like in the example of Docker plugin for Jenkins. I see that the groovy file Docker.groovy is in:…
Rijo Simon
  • 777
  • 3
  • 15
  • 35
7
votes
4 answers

Workspace path in job DSL within Jenkins pipeline

I am creating a jenkins pipeline job to seed jobs using the jenkins job DSL plugin. How do I get the workspace path inside the DSL file? The jenkins pipeline code is as such: #!groovy node{ stage("build jobs"){ ws{ git poll:…
Graeme
  • 308
  • 1
  • 5
  • 15
7
votes
1 answer

Can a single seed job process DSLs from multiple repos?

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…
evadeflow
  • 4,704
  • 38
  • 51
7
votes
1 answer

Trying to loop through an array and pass each value into a gradle task

I'm trying to do a series of things which should be quite simple, but are causing me a lot of pain. At a high level, I want to loop through an array and pass each value into a gradle task which should return an array of its own. I then want to use…
MDalt
  • 1,681
  • 2
  • 24
  • 46
7
votes
1 answer

How can I set the job timeout using the Jenkins DSL

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…
pwan
  • 2,894
  • 2
  • 24
  • 38
7
votes
1 answer

Using Jenkins Job-DSL Configure block to place custom steps in particular positions

Using the job-dsl-plugin I am attempting to script the configuration of a fair number of Jenkins jobs which have previously been configured manually. One flavour of these jobs has multiple steps including a couple which use the XShell plugin, this…
Ed Randall
  • 6,887
  • 2
  • 50
  • 45
7
votes
1 answer

Groovy slash operator (Jenkins job-dsl)

We would like to understand a couple of legacy job-dsl scripts but don't know what "slash operator" means in this context (as it cant be division): def command = (shells.first() / command) We have tried to look it up in several Groovy books but…
user1724641
  • 331
  • 1
  • 11
7
votes
3 answers

How to use Jenkins JobDSL to set 'Check out to specific local branch' in Git Plugin?

I have the following: job { scm { git { remote { url(GIT_URL) } branch('master') } } } It works pretty well but I would like for it to set 'Check out to specific local branch' to 'master'. How is that done? I…
Noel Yap
  • 18,822
  • 21
  • 92
  • 144
6
votes
1 answer

How to configure Jenkins GitHubPullRequestBuilder plugin using Job DSL

I am setting up webhook integration between a private GitHub repository and a Jenkins build. I configure jobs exclusively using Job DSL groovy scripts (I'm open to switching to another programmatic job configuration mechanism, but I will not accept…
JakeRobb
  • 1,711
  • 1
  • 17
  • 32
1
2
3
56 57