In the whitesource agent config file, use the gradle.additionalArguments to set the env variables
gradle.additionalArguments=-Partifactory_user=${artifactory_user} -Partifactory_password=${artifactory_password}
Nothing worked. This is the only solution that worked for me.