2

I am passing in System variables using IntelliJ's Run/Debug Configuration tool as follows:

Tasks: clean headlessTest
VM options: -Denv=test -DstoreCode=189 -Ddept=apparel
Arguments: -PdepartmentJourney=department_journey
Environment variables: UI_USERNAME=test;UI_PASSWORD=12345...//These are passed in the pipeline script in CI

This issues the local Gradle command of:

./gradlew clean headlessTest -Denv=test -DstoreCode=189 -Ddept=apparel -PdepartmentJourney=department_journey --no-daemon

And in my CI pipeline:

def setEnvironmentVariables(){
env.UI_USERNAME = getFromSecrets....
env.UI_PASSWORD = getFromSecrets....
}

./gradlew clean headlessTest -Denv=${env.ENVIRONMENT} - DstoreCode=${env.storeCode} -Ddept=${env.dept} -PdepartmentJourney=department_journey --no-daemon

I assume this calls the System.setProperty(String key, String value) method at runtime.

When I debug the code using getProperty only the storeCode value is set, with dept being set to null.

I am using the same getProperty(String key) method for each.

Running from the Terminal and in a pipeline also sees the apparel == null.

Is there an obvious reason?

Steerpike
  • 1,712
  • 6
  • 38
  • 71
  • I actually cannot reproduce that behavior. Could you please specify how exactly you set your properties in IntelliJ's configuration and the run command IntelliJ creates from your options? – fhueser Jun 22 '20 at 12:32
  • @fhueser thank you, I have added some more info; hope it helps. – Steerpike Jun 22 '20 at 12:52
  • It's really a shot in the dark as I don't see anything that's obviously wrong. Maybe it's due to process forking... check this discussion, maybe it helps https://stackoverflow.com/questions/23689054/problems-passing-system-properties-and-parameters-when-running-java-class-via-gr/23689696#23689696 – fhueser Jun 22 '20 at 13:22
  • @fhueser thank you, that has helped ~ I had forgotten to set the properties also in the Gradle task in build.gradle. However, now both variables hold the value 189 :( – Steerpike Jun 22 '20 at 13:42
  • @fhueser rebuilt and all working! Thank you!! – Steerpike Jun 22 '20 at 13:45
  • nice, glad it helped! :) – fhueser Jun 22 '20 at 13:49

0 Answers0