1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/documentation/docs/steps/mavenExecute.md
Florian Wilhelm eaf5479e9c
Fix maven parameter handling (#1493)
Avoid maven error `Unknown lifecycle phase \"-\"` when the value of a define contains `-`.

Don't split and trim maven arguments. Expect they come in as a list, keep them as list.

This is a breaking change compared to the old Groovy implementation which relied on using a shell for calling maven.

As an example, consider this diff:

```diff
-        goals: 'org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate',
-        defines: "-Dexpression=$pomPathExpression -DforceStdout -q",
+        goals: ['org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate'],
+        defines: ["-Dexpression=$pomPathExpression", "-DforceStdout", "-q"],
```
2020-05-06 17:43:32 +02:00

37 lines
1.1 KiB
Markdown

# ${docGenStepName}
## ${docGenDescription}
## ${docGenParameters}
!!! note "Breaking change in `goals`, `defines` and `flags` parameters"
The `goals`, `defines` and `flags` parameters of the step need to be lists of strings with each element being one item.
As an example consider this diff, showing the old api deleted and the new api inserted:
```diff
-goals: 'org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate',
-defines: "-Dexpression=$pomPathExpression -DforceStdout -q",
+goals: ['org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate'],
+defines: ["-Dexpression=$pomPathExpression", "-DforceStdout", "-q"],
```
Additionally please note that in the parameters _must not_ be [shell quoted/escaped](https://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_03.html).
What you pass in is literally passed to Maven without any shell interpreter inbetween.
The old behavior is still available in version `v1.23.0` and before of project "Piper".
## ${docGenConfiguration}
## ${docJenkinsPluginDependencies}
## Exceptions
None
## Example
```groovy
mavenExecute script: this, goals: ['clean', 'install']
```