Can't create freeStyleJobs, getting "IllegalArgumentException: Expected named arguments"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Can't create freeStyleJobs, getting "IllegalArgumentException: Expected named arguments"

Christian
Hello,

I am trying to use the nexus-artifact-uploader-plugin to upload the packaged war files to my nexus 3 repository. The nexus-artifact-uploader provides an example which I modified, but for some reason it already fails when it gets to the name.

This is my code:
def uploadToNexus(module) {
  def groupId = "com.example"
  def moduleVersions = [
          "client-module": "1.0.0-SNAPSHOT",
          "server-module": "1.0.0-SNAPSHOT",
  ]

  def moduleVersion = moduleVersions.get(module)
  def jobName = "${fixModuleName(module)}NexusArtifactUploaderJob"

  echo "will run freeStyleJob ${jobName} now..."
  freeStyleJob(jobName) {
    steps {
      nexusArtifactUploader {
        nexusVersion('nexus3')
        protocol('http')
        nexusUrl('nexus:8081')
        groupId(groupId)
        version(moduleVersion)
        repository('maven2_central')
        credentialsId('nexus_admin')
        artifact {
          artifactId('${module}')
          type('war')
          classifier('debug')
          file('${module}.war')
        }
      }
    }
  }
}

When I run this on Jenkins I get the following error:
java.lang.IllegalArgumentException: Expected named arguments but got [clientmoduleNexusArtifactUploaderJob, org.jenkinsci.plugins.workflow.cps.CpsClosure2@63d801fc]
  at org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java:511)
  at org.jenkinsci.plugins.workflow.cps.DSL.invokeDescribable(DSL.java:291)
  at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:153)
  at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
  at sun.reflect.GeneratedMethodAccessor463.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  ...


I checked many sites and tried to find my error but it just won't work. I also tried to pass a static string instead of a variable but it doesn't work either.

What can I do now?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f2a6b0b7-3c39-40a4-b9bf-3fd3d03af2cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Can't create freeStyleJobs, getting "IllegalArgumentException: Expected named arguments"

Victor Martinez
As far as I see, stacktrace output seems like a pipeline issue, although the snippet looks like a JobDSL script. Can you confirm if you are running the snippet under the 'Process Job DSLs' build section?

Cheers

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d1849541-443c-49cf-96cd-566cab16dfb8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.