Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set environment variable with whitespaces in the value using withEnv in Jenkinsfile

I need to have the effect of MAVEN_OPTS="-server -Xms4G -Xmx4G" mvn clean verify -f pom.xml with Jenkinsfile.

The below does not work. What is the correct syntax for it?

withEnv(['MAVEN_OPTS="-server -Xms4G -Xmx4G"']) {
    sh 'mvn clean verify -f pom.xml'
}
like image 610
bobah Avatar asked Sep 01 '25 21:09

bobah


1 Answers

Just remove double quotes after the equals sign

withEnv(['MAVEN_OPTS=-server -Xms4G -Xmx4G']) {
    sh 'mvn clean verify -f pom.xml'
}
like image 57
Vitalii Vitrenko Avatar answered Sep 03 '25 16:09

Vitalii Vitrenko