question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

seed script fails to create jobs using job DSL

See original GitHub issue
  • [latest ] Jenkins version
  • [1.4] Plugin version
  • [docker ] OS

When using following well-indented simple job dsl script to create seed jobs, the startup fails. The jobs section looks as :

jenkins:
  systemMessage: "Welcome to Jenkins "
.
.
jobs:
  - script: >
      job('apps'){}
      job('infra-tools'){}

The error seen in docker logs is

Caused by: io.jenkins.plugins.casc.ConfiguratorException: jobs: error configuring 'jobs' with class io.jenkins.plugins.casc.support.jobdsl.SeedJobConfigurator configurator
	at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:626)
	at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:649)
	at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:545)
	at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:275)
	at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:267)
	... 13 more
Caused by: groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.dsl.jobs.FreeStyleJob.job() is applicable for argument types: (java.lang.String, script$_run_closure2) values: [infra-tools, script$_run_closure2@5f0b2f55]

However same script when run from DSL job manually ran fine.

Processing provided DSL script
Added items:
    GeneratedJob{name='apps'}
    GeneratedJob{name='infra-tools'}
Finished: SUCCESS

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
imalik-rmscommented, Dec 24, 2018

ok so i found out the issue after debugging specially using this debugging line -> https://github.com/imalik-rms/configuration-as-code-plugin/blob/7aaa58cbc491018d9e23d63aad61af75c7647c26/support/src/main/java/io/jenkins/plugins/casc/support/jobdsl/SeedJobConfigurator.java#L67 that when you dont have a newline between any job definitions, it screams error

        job('imran') {

        }
        folder("testing") {

        }

is interpreted as

        job('imran') {

        }folder("testing") {

        }

so it gives Caused by: javaposse.jobdsl.dsl.DslScriptException: (script, line 1) No signature of method: javaposse.jobdsl.dsl.jobs.FreeStyleJob.folder() is applicable for argument types: (java.lang.String, script$_run_closure2) values: [testing, script$_run_closure2@28f04c72] error. however , the following runs fine since it got newline between jobs/folders DSL definition

        job('imran') {

        }


        folder("testing") {

        }
1reaction
ewelinawilkoszcommented, Dec 21, 2018

I need to have a look then, will get back to you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fail the seed job when using the Jenkins Job DSL plug-in
in Jenkins pipelines it is better to use 'error' step if (! binding.variables.get(it)?.trim()) { error "This script expects the $it environment variable to ......
Read more >
Jobs created from SEED job no longer getting updated
It doesn't matter if it's an existing SEED job or a new one. ... Seed job's console log: Processing DSL script MyDeploymentPipeline.groovy. Existing...
Read more >
Jenkins Tutorial: Implementing a Seed Job - HappyCoders.eu
Tutorial, part 3: Configure Jenkins Script Security - Create a seed job to automatically generate Jenkins jobs for new Java projects.
Read more >
How To Automate Jenkins Job Configuration Using Job DSL
The seed job is a normal Jenkins job that runs the Job DSL script; in turn, the script contains instructions that create additional...
Read more >
Jenkins DSL seed job - Technotes
Instead of selecting “Use the provided DSL script”, ... Running Jenkins jobs from the Git repository – Groovy Sandbox error message.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found