0
votes

I'm a noob to the groovy and came across the job-dsl Jenkins plugin which suits my requirement.

My requirement is to replicate the existing Jenkins Job (say A) and create a new job B with only change as subversion URL (in the subversion plugin) in the Job B.

I tried out developing a basic job-dsl script like below and develop further from there that suits my aforementioned requirement.

job('ci') {
    description 'Build and test the app.'
    scm {
        svn('https://svn.mydomain.com/repo/project1/trunk')
    }
}

Below is the issue Im facing, I tried figuring out the answer without any luck and would be really grateful for any help.

Using dsl from string
ERROR: Build step failed with exception
groovy.lang.MissingMethodException: No signature of method: Script1.job() is applicable for argument types: (java.lang.String, Script1$_run_closure1) values: [PROJ-unit-tests, Script1$_run_closure1@199fab4]
Possible solutions: job(groovy.lang.Closure), run(), run(), any(), wait(), dump()
1
@daspilker :Could you suggest me some idea here. Thanks. - baba yaga
Your DSL script seems to be correct. It runs on the playground without problem. Do you use the "Process Job DSLs" build step? You need to provide more context. - daspilker
@daspilker: Yes , In Jenkins , I use - "Process Job DSLs" build step and just entered my sample code and trying building the job. but the same issue: Building in workspace D:\Jenkins\workspace\Seed_Proj Using dsl from string ERROR: Build step failed with exception groovy.lang.MissingMethodException: No signature of method: Script1.freeStyleJob() is applicable for argument types: (java.lang.String) values: [SimpleJob] at javaposse.jobdsl.dsl.DslScriptLoader.parseScript(DslScriptLoader.java:72) at javaposse.jobdsl.dsl.DslScriptLoader.runDsl(DslScriptLoader.java:39) - baba yaga
Are you using the latest version of the Job DSL plugin? - daspilker
@daspilker : I'm unable move forward and not sure how to create a new Job (Job B) keeping Job A as a template. The only change in the Job B should be a different SVN branch URL that of Job A. looking forward for your valuable suggestion. - baba yaga

1 Answers

2
votes

If something fundamental is not working, try to update the Job DSL plugin to the latest version and try to get the tutorial steps (you can skip #4) working.

See the comments above for details.