Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins wraps quotes around java system properties

I'm using Jenkins to execute a shell script at as a post build step. The problem is that jenkins wraps quotes around the system properties I'm passing in. Therefore the application can't see that any system properties have been passed in.

If Jenkins wrapped them in double quotes it would be fine but single quotes doesn't work.

Raw shell script:

java -jar -Dnetwork.configuration=Transport.uri=amqp://localhost:5672/stable,transportServer.database.driver=com.mysql.jdbc.Driver,brokerServer.database.jpa=MYSQL "${WORKSPACE}/ffiq-integration/target/PackRunner.jar" -pack "${WORKSPACE}/ffiq-integration/src/main/resources" -name JenkinsIntegrationTests

Jenkins executes:

java -jar '-Dnetwork.configuration=Transport.uri=amqp://localhost:5672/stable,transportServer.database.driver=com.mysql.jdbc.Driver,brokerServer.database.jpa=MYSQL' "${WORKSPACE}/ffiq-integration/target/PackRunner.jar" -pack "${WORKSPACE}/ffiq-integration/src/main/resources" -name JenkinsIntegrationTests

Is there a way to stop Jenkins doing this?

Thanks.

like image 468
Nick Avatar asked Oct 21 '25 23:10

Nick


1 Answers

The single quotes shouldn't be a problem, the java process will still see the whole -Dname=val as a single option. The more likely problem is that you need to swap round the order of the arguments, i.e. it should be

java -D.... -jar ".../PackRunner.jar" <arguments-to-PackRunner-main-class>

(with no other intervening arguments between the -jar and the JAR file name).

like image 112
Ian Roberts Avatar answered Oct 23 '25 13:10

Ian Roberts