0

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()
baba yaga
  • 119
  • 2
  • 10
  • @daspilker :Could you suggest me some idea here. Thanks. – baba yaga Feb 02 '17 at 09:29
  • Your DSL script seems to be correct. It runs on the [playground](http://job-dsl.herokuapp.com/) without problem. Do you use the "Process Job DSLs" build step? You need to provide more context. – daspilker Feb 02 '17 at 09:51
  • @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 Feb 02 '17 at 10:01
  • Are you using the latest version of the Job DSL plugin? – daspilker Feb 02 '17 at 10:04
  • @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 Feb 02 '17 at 10:04
  • @daspilker : I'm using V1.43 Job DSL plugin and my Jenkins version is 2.32.1 – baba yaga Feb 02 '17 at 10:06
  • Update to the latest version and try to get the [tutorial](https://github.com/jenkinsci/job-dsl-plugin/wiki/Tutorial---Using-the-Jenkins-Job-DSL) steps (you can skip #4) working. – daspilker Feb 02 '17 at 10:11
  • @daspilker : Thanks much , latest version did the trick. I will continue to develop my script to achieve my aforementioned requirement – baba yaga Feb 02 '17 at 10:19

1 Answers1

2

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.

daspilker
  • 8,154
  • 1
  • 35
  • 49