How do I specify "Ignore missing files" in the dsl job-step?

439 views
Skip to first unread message

Peter McEvoy

unread,
Jan 4, 2018, 5:29:26 AM1/4/18
to job-dsl-plugin
I have a root DSL job that creates other DSL jobs (one per branch) using the "dsl" job step  (I know, that's a hard statemement to parse!):

steps {
     environmentVariables
{
          env('BranchName', "${branchName}")
          env('RepoUrl', "${repoUrl}")
          }
          dsl {
               external('Src\\Jenkins\\GitFolders.groovy')
               external('Src\\Jenkins\\GitIncremental.groovy')
               external('Src\\Jenkins\\GitFull.groovy')
               removeAction('DELETE')
               removeViewAction('DELETE')
               ignoreExisting(false)
          }
}


However for some branches, it is possible that some of the "external" .groovy files will not exist.  The UI exposes an option to "Ignore missing files" but there is no documentation in API docs for DSL that expains how to set that...  Any pointers on how I can set it (perhaps using a "Configure" block?)

Sincerely
Pete

Victor Martinez

unread,
Jan 4, 2018, 6:26:36 AM1/4/18
to job-dsl-plugin
Hey Peter,

As far as I see in the embedded api viewer, that particular option is there, can you confirm whether the below URL works?

- <YOUR_JENKINS_URL>/plugin/job-dsl/api-viewer/index.html#path/javaposse.jobdsl.dsl.helpers.step.StepContext.jobDsl-ignoreMissingFiles

Please replace YOUR_JENKINS_URL accordingly.

jobDsl api docs:

jobDsl {
  • // Newline separated list of additional classpath entries for the Job DSL scripts.
    additionalClasspath(String value)
  • // If checked, the build will be marked as failed if a plugin must be installed or updated to support all features used in the DSL scripts.
    failOnMissingPlugin(boolean value)
  • // Ignore previously generated jobs and views.
    ignoreExisting(boolean value)
  • // Ignore missing DSL scripts.
    ignoreMissingFiles(boolean value)
  • // Determines how relative job names in DSL scripts are interpreted.
    lookupStrategy(String value)
  • removedConfigFilesAction(String value)
  • // Specifies what to do when a previously generated job is not referenced anymore.
    removedJobAction(String value)
  • // Specifies what to do when a previously generated view is not referenced anymore.
    removedViewAction(String value)
  • // If checked, runs the DSL scripts in a sandbox with limited abilities.
    sandbox(boolean value)
  • // DSL Script, which is groovy code.
    scriptText(String value)
  • // Newline separated list of DSL scripts, located in the Workspace.
    targets(String value)
  • // If checked, marks the build as unstable when using deprecated features.
    unstableOnDeprecation(boolean value)
  • useScriptText(Boolean value)
}

In my case, I'm based on the latest version -> 1.66

Cheers

Peter McEvoy

unread,
Jan 4, 2018, 6:59:41 AM1/4/18
to job-dsl-plugin
Oh - my bad! Yes: that entry is there and in fact the entire "jobDsl" step is there, but has compeltely different documentation to the "dsl" step...  are these the same thing??  (in fact, the docs under the "dsl" step are a lot better than the ones under the "jobDsl" step as they include examples.. but I can probably figure out the correct translation to what I am using)

Peter McEvoy

unread,
Jan 4, 2018, 7:13:16 AM1/4/18
to job-dsl-plugin
My updated DSL script is now, and it creates the correct jobs.  Cheers!  (but it would probably be a good idea to remove that older documentation...)

jobDsl {
targets("""Src/Jenkins/GitFolders.groovy
Src/Jenkins/GitIncremental.groovy
Src/Jenkins/GitFull.groovy
""")
removedJobAction('DELETE')
removedViewAction('DELETE')
ignoreExisting(false)
ignoreMissingFiles(true)
}


Sincerely
Pete
Reply all
Reply to author
Forward
0 new messages