Reputation: 1603
I am running a Jenkins instance hosted by Cloudbees. I installed the Jenkins EnvInject plugin and I added a Pre-Build step. I added a variable under "Properties Content":
CERT_HOME=/private/{my-domain-name}/dev
The CERT_HOME
path and actual certificates are under the WebDAV directory that Cloudbees provides.
In a JUnit test, I try to access the environment variable like this:
private static final String CERT_HOME = System.getenv("CERT_HOME");
However, it returns null.
Under the build, I do see the environment variable:
CERT_HOME=/private/{my-domain-name}/dev
How do I read an environment variable in my JUnit test that I set using the EnvInject plugin?
Upvotes: 2
Views: 4279
Reputation: 14096
Maven surefire tries to give you a clean environment within the forked process, have a look at using environmentVariables
with ${env.CERT_HOME}
to try passing it through
Upvotes: 3