I have a freestyle project with a powershell command, using GitHub - jenkinsci/powershell-plugin: Jenkins powershell plugin
(the github project doesn’t allow creating issues, so Im posting here instead)
All the command has to do is invoke Maven, using the Maven wrapper script like so:
.\mvnw.cmd --% install --threads 3 -Dgib.disable -Dremote.name=argo -Dbuild.name=%JOB_BASE_NAME%
The reason for the “–%” is to stop Powershell doing any further parsing, and so treat gib.disable as a string not the disable property of the gib object. See Tokenizer treats `.` as a separator when parsing a parameter token, which causes problem to argument parsing for native commands · Issue #15541 · PowerShell/PowerShell · GitHub
My freestyle project builds fine. But now I want to convert it to a pipeline. Here’s my Jenkinsfile
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '*/master']],
extensions: [],
userRemoteConfigs: [[
name: 'origin',
refspec: '+refs/heads/master:refs/remotes/origin/master',
url: 'git@cassius:delany/maven-hello-world.git'
]]
])
}
}
stage('Build') {
steps {
pwsh '.\\mvnw.cmd --% install --threads 3 -Dgib.disable -Dremote.name=argo -Dbuild.name=%JOB_BASE_NAME%'
}
}
}
}
And here’s the output for the Build stage
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] pwsh
e[91mParserError: e[0mC:\ws\releases\TEP-2.2.0-RC13@tmp\durable-c60613db\powershellScript.ps1:1
e[96mLine |
e[96m 1 | e[0m try e[96m{e[0m .\mvnw.cmd --% install --threads 3 -Dgib.disable -Dremote.name= …
e[96m | e[91m ~
e[91me[96m | e[91mMissing closing '}' in statement block or type definition.
e[0m
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
Question 1: what is the different betwen using “pwsh” and “powershell”?
Question 2: what’s with the ansi escape sequences in the output, e.g. “[91m”
Question 3: why doesn’t it fail the build?
Question 4: what is it actually complaining about and how can I fix my build?
Change anything, except that the solution must
- use a Jenkinsfile
- use Maven wrapper
- allow passing cli arguments to Maven such as “-Dremote.name=argo”