Skip to content

Setting up Jenkins

Vivek Shresta Bandaru edited this page Mar 22, 2020 · 1 revision
  • Now that you've created a new VM for installing the Jenkins instance, you can SSH into your VM using ssh ubuntu@jenkins_instance_ip and your key.

  • Our VM's comes preinstalled with java 8 jre, and since Jenkins is built on Jaeva, please install Java 8 jdk. Command for installing Java8 jdk : sudo apt-get update sudo apt install openjdk-8-jdk

  • Also install grade. Commands for installing gradle: wget https://services.gradle.org/distributions/gradle-5.1-bin.zip -P /tmp sudo unzip -d /opt/gradle /tmp/gradle-*.zip

  • Setting up environment variables. sudo nano /etc/profile.d/gradle.sh export GRADLE_HOME=/opt/gradle/gradle-5.1 export PATH=${GRADLE_HOME}/bin:${PATH} sudo chmod +x /etc/profile.d/gradle.sh source /etc/profile.d/gradle.sh

  • Install Jenkins on your VM using the following commands: wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add - sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list' sudo apt-get update sudo apt-get install jenkins

  • You can check the status of your Jenkins installation using systemctl status Jenkins

  • Commands to start, stop and restart Jenkins: sudo systemctl start jenkins.service sudo systemctl stop jenkins.service sudo systemctl restart jenkins.service

  • Now that Jenkins is installed, you can use your Jenkins instance using the IP address of your VM and the port 8080. The initial screen will ask for the intialAdminPassword. sudo cat /var/lib/jenkins/secrets/initialAdminPassword outputs the initial admin password. Copy paste this onto your browser for logging in.

  • Setup your profile on the Jenkins instance.

  • Go to Manage Jenkins option, Manage Plugins, Available and then install the below-mentioned plugins: GitHub Integration Plugin Gradle Plugin SSH Build Agents plugin

  • Next step, go to Manage Jenkins -> Global Tool Configuration -> Configure JDK, Gradle, and Git Path.

  • Next, if you're using a private repository, configure your github password on your Jenkins machine using Credentials on the Jenkins home page. The same thing should be done if you're planning on pulling or pushing to Dockerhub.

  • Finally, for creating a new pipeline, follow the following steps: Homepage -> New-item -> Enter the item name, hit on Pipeline and click the okay button -> Enter description -> Click on Github project and give your project url -> Click on 'GitHub hook trigger for GITScm polling' if there's a webhook enabled on your github project or else Click on poll scm and enter '* * * * *' for polling every minute.

  • Finally, in the Pipeline, choose Pipeline script from SCM -> Choose Git -> Paste your repo link and enter the script path for your Jenkinsfile.

This is how a pipeline is created on Jenkins.

Clone this wiki locally