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

59 views
Skip to first unread message

Christian

unread,
Sep 28, 2017, 3:21:27 AM9/28/17
to Jenkins Users
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?

Victor Martinez

unread,
Sep 28, 2017, 6:28:10 PM9/28/17
to Jenkins Users
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
Reply all
Reply to author
Forward
0 new messages