Pete
Pete

Reputation: 1650

Accessing OS environment variables within a Jenkinsfile

Is this possible? I'm trying to access the linux env variable M2_REPO inside my Jenkinsfile using the Jenkins pipeline plugin, however it's constantly empty. I can run it on my bash shell just fine:

root@host-VirtualBox:~#  echo $M2_REPO
/media/sf_apache-maven-repository

But running the command in a Jenkinsfile doesn't print anything:

sh 'echo $M2_REPO' 

Does the Jenkinsfile have access to OS env variables?

Upvotes: 0

Views: 1686

Answers (1)

Pete
Pete

Reputation: 1650

When I set the variable using the Environment Inject plugin in jenkins it worked..

Upvotes: 1

Related Questions