Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saiyam1814/de8e7cafe474260ae4b3baf3a1d46dd6 to your computer and use it in GitHub Desktop.
Save saiyam1814/de8e7cafe474260ae4b3baf3a1d46dd6 to your computer and use it in GitHub Desktop.
How To run MAVEN commands as Jenkins User
You might encounter into an issure where you are running a Jenkins Job and you have Maven commands in that and you might be facing 2 types of issues:
1) mvn command not found
2) cannot create the repository
So if you just have installed maven as root so you need to change the settings.xml
go to settings.xml and put <localRepository>/var/lib/jenkins/.m2/repository</localRepository>
also export the environment variables.
export M2_HOME=/usr/local/apache-maven-3.5.3
export PATH=$PATH:$M2_HOME/bin
export JAVA_HOME=/opt/jdk1.8.0_171
Now Jenkins user also might not be able to get these environmet variables so set them as environment variables in jenkins configuration as well.
Once you have the correct Environment variables set and the localRepository you are GOOD to GO..!
#DevOpsRocks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment