Nick
Nick

Reputation: 1269

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.

Upvotes: 4

Views: 1165

Answers (1)

Ian Roberts
Ian Roberts

Reputation: 122364

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).

Upvotes: 4

Related Questions