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
5
votes
2 answers

Is a Jenkinsfile in pure Groovy? What Groovy language construct is used in `steps` in a Jenkinsfile?

What Groovy language construct, syntax or control structure is used in the following code fragment in a Jenkinsfile? stage('Stage 1') { steps { // One or more steps } } i.e. What are blocks in Jenkinsfile, in terms of pure Groovy…
Sohail Si
  • 2,750
  • 2
  • 22
  • 36
5
votes
1 answer

Setting Jenkins Parameterized Scheduler Plugin using job dsl

I am trying to add a parameterized cron job using jenkins job dsl. However, every time I try to add the job I see the following error: No signature of method: javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.parameterizedTimerTrigger() is…
cbwsports
  • 51
  • 3
5
votes
1 answer

How to pass paramaters to a pipelineJob in DSL

I have very similar pipeline jobs that have only differences are parameters. The goal is to create these jobs by passing parameters in a DSL script without any code duplication. I followed this article. So If you run the DSL script below after you…
onuralp
  • 890
  • 1
  • 9
  • 17
5
votes
2 answers

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

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…
bartimar
  • 3,374
  • 3
  • 30
  • 51
5
votes
2 answers

Jenkins job DSL plugin - hidden parameter

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:…
5
votes
2 answers

Add parameter "Build Selector for Copy Artifact" using Jenkins DSL

I'm converting a Jenkins job from a manual configuration to DSL which means I'm attempting to create a DSL script which creates the job(s) as it is today. The job is currently parameterized and one of the parameters is of the type "Build Selector…
shaneoh
  • 442
  • 2
  • 8
  • 26
5
votes
3 answers

How to set git credentials using credentials parameter

I'm writing a job-dsl seed job. The seed job needs to be able to generate from either github.com or from my companies github enterprise server. I'd like to keep one job rather than have two. In each case I would like jenkins to be Authenticated. …
Duane
  • 4,572
  • 6
  • 32
  • 33
5
votes
2 answers

Create a list view in a subfolder using the job DSL plugin in Jenkins

In Jenkins you can easily create a list view with the Job DSL listView("myView") { jobs { regex(".*") } } but if you try to create a list view within a folder, the folder will be created but not the…
nebffa
  • 1,529
  • 1
  • 16
  • 26
5
votes
1 answer

How can I get the seed job's name inside a Jenksin Job DSL script?

I'm using a Freestyle project / job with a Process Job DSLs build step as provided by the Jenkins Job DSL plugin, i.e. that is the "seed" job. How can I, from within the code provided by Use the provided DSL script, get the seed job's name? I've…
sschuberth
  • 28,386
  • 6
  • 101
  • 146
5
votes
2 answers

How to access list of Jenkins job parameters from within a JobDSL script?

I would like to save the parameters passed into a JobDSL job. I know I can refer to individual parameters but I would like to make the code generic. How would I access the list of parameters passed to the job? The current code looks something…
Noel Yap
  • 18,822
  • 21
  • 92
  • 144
5
votes
1 answer

Configure Jenkin's SonarQube section using Job-DSL

Using Job-DSL we can configure a C# project in Jenkins. The SonarQube tasks is giving us a hard time. StepContext.metaClass.sonar = { -> NodeBuilder nodeBuilder = new NodeBuilder() stepNodes <<…
Francois
  • 10,730
  • 7
  • 47
  • 80
5
votes
3 answers

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

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…
Aimee
  • 51
  • 1
  • 3
4
votes
1 answer

How make dynamic change stage name in Jenkinsfile Declarative pipeline?

I have Jenkinsfile (Scripted Pipeline) def template1 = "spread_sshkeys" node { // Clean before build stage('Checkout') { deleteDir() checkout scm sh "git submodule foreach --recursive git pull origin master"; } …
4
votes
1 answer

How to set the discovery modes for multibranch job created by Job DSL

I'm new to Jenkins and I'm trying to figure something out. Is there a way to add Branch Sources behavior via Groovy. This is to analyse GitHub projects in SonarQube using Jenkins. I'm creating a multi-branch pipeline but can't seem to figure out how…
Metro
  • 873
  • 8
  • 19
4
votes
2 answers

Groovy multiline string interpolation whitespace

I am trying to generate some generic Groovy code for Jenkins but I seem to have trouble with multi line strings and extra white space. I've tried everything I could find by Googling but I can't seem to get it working. My issue isn't related to…
Serban Cezar
  • 507
  • 1
  • 8
  • 19