0

I have a shared library for a project specific Jenkins Setup.

One of my files in vars/gradle.groovy looks as follows:

/**
 * simple wrapper around the ./gradlew command in a repository.
 *
 *
 * @param command : the gradle command that will be executed.
 *
 * @return nothing, except for status codes.
 */
void call(String command) {
    sh "./gradlew ${command}"
}

return this

When I try to call it from my actual project code (declarative Jenkinsfile) like this:

...
stage('Gradle Build + Docker Build (against remote DB)') {
    steps {
        gradle "-PtestEnv=stage --continue build"
    }
}
...

I get the following error:

WorkflowScript: 97: Step does not take a single required parameter - use named parameters instead @ line 97, column 17.
                   gradle "-PtestEnv=stage --continue build"

Any ideas what I'm doing wrong? Other functions use named parameters, and they work out of the box.

But in this case I would prefer a simple String parameter to make the interface of the method as convenient as possible.

Thanks!

Sebastian
  • 1,873
  • 4
  • 25
  • 57
  • Can you try this?: gradle command:"-PtestEnv=stage --continue build" – Mzzl Sep 16 '19 at 14:14
  • Similar issue as I would have expected: `WorkflowScript: 118: Invalid parameter "command", did you mean "tasks"? @ line 118, column 24. gradle command: "-PtestEnv=stage --continue testResourceIntegration"` – Sebastian Sep 16 '19 at 15:10
  • Try wrapping your `gradle` method call inside a `script {}` block. That is required anyway for global var method invokes and may be your only issue. – Matthew Schuchard Sep 16 '19 at 16:03

0 Answers0