Prerequisites:
- Create an account on https://github.com
- Create an account on https://mymavenrepo.com
- Install git client on Jenkins server (node)
- Install JDK (javac) on Jenkins server (node) and set path in Jenkins console.
- Add credentials for GITHUB account on jenkins server as below Jenkins -> Credentials -> System -> Add Credentials
- Set JAVA_HOME in Global Tool Configuration Click Add JDK -> Nanme = JAVA & JAVA_HOME = /usr/lib/jvm/java-openjdk
- Also Jenkins needs to know where your Maven is installed, set this in GTC Manage plugins -> GCT -> Maven installation -> Add Maven -> Name = maven_3_5_0, check install from Apache. Apply Save.
- Install git client on your jenkins server
- Set git path in GCT as well. Click git -> Name = Default & Path to git executable = git (Optional)
- New item -> Select Maven project
- Check GitHub Project, Project URL = https://github.com/rajeevsh990/jenkins-example/
- Check Git in SCM section. Set repository url = https://github.com/rajeevsh990/jenkins-example.git (clone from git web console). select git credentials.
- Check Build whenever a SNAPSHOT dependency is built (optional)
- Check GitHub hook trigger for GITScm polling (optional)
- Build step: Root POM = pom.xml , Goals = clean deploy
- Apply Save.
- Build.