Thanks,
sounds like what I was looking for. But then: Any ideas, what's wrong in my
script?
pipeline {
agent any
tools {
maven 'Maven3'
jdk 'Java8'
}
stages {
stage ('afw-core') {
steps {
withMaven(
// Maven installation declared in the Jenkins "Global
Tool Configuration"
maven: 'Maven3',
// Use `$WORKSPACE/.repository` for local repository
folder to avoid shared repositories
mavenLocalRepo: '.repository',
) {
if (isUnix()) {
sh 'mvn -fafw/afw-core/pom.xml -Pjacoco
-Dmaven.test.failure.ignore=true clean install'
} else {
bat 'mvn.cmd -fafw/afw-core/pom.xml -Pjacoco
-Dmaven.test.failure.ignore=true clean install'
}
}
}
}
stage ('afw-bootstrap') {
steps {
withMaven(
// Maven installation declared in the Jenkins "Global
Tool Configuration"
maven: 'Maven3',
// Use `$WORKSPACE/.repository` for local repository
folder to avoid shared repositories
mavenLocalRepo: '.repository',
) {
if (isUnix()) {
sh 'mvn -fafw/afw-bootstrap/pom.xml -Pjacoco
-Dmaven.test.failure.ignore=true clean install'
} else {
bat 'mvn.cmd -fafw/afw-bootstrap/pom.xml -Pjacoco
-Dmaven.test.failure.ignore=true clean install'
}
}
}
}
}
}
The error message I am getting:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
failed:
WorkflowScript: 17: Expected a step @ line 17, column 9.
if (isUnix()) {
^
WorkflowScript: 34: Expected a step @ line 34, column 9.
if (isUnix()) {
^
On Sunday, January 24, 2021 at 5:54:26 PM UTC+1 [email protected] wrote:
> Hello
> you probably want to use
> https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#isunix-checks-if-running-on-a-unix-like-node
>
>
> On Saturday, 23 January 2021 at 21:19:43 UTC+1 [email protected] wrote:
>
>>
>> Hi,
>>
>> I've got a pipeline file, that should be executable on a Windows build
>> server, and on a Linux build server. The pipeline is launching Maven as
>> follows:
>>
>> On Linux:
>>
>> sh "mvn <MAVEN_OPTIONS>"
>>
>> But on Windows, this appears not to work, so I've got to use:
>>
>> bat "mvn.cmd <MAVEN_OPTIONS>"
>>
>> Right now, I can use either of these steps, so have to choose between
>> Windows, and Linux. Is there any possibility to get this portable? I am
>> thinking something like
>>
>> if (isWindows()) {
>> bat "mvn.cmd <MAVEN_OPTIONS>"
>> } else {
>> sh "mvn <MAVEN_OPTIONS>"
>> }
>>
>> Thanks,
>>
>> Jochen
>>
>>
>>
>>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/e083204b-5dcd-4765-bbad-d9fa0d96878fn%40googlegroups.com.