Posts

Showing posts with the label Jenkins

Jenkins Declarative Pipeline

Image
Sample Jenkins Declarative Pipeline def A = false def B = true pipeline { agent any tools { maven 'MVN' jdk 'JDK' } stages { stage('Build Stage') { steps { git "https://github.com/nishantautomationlabs/nal-junitmockito.git" sh "mvn -U clean compile install -DskipTests" echo 'Build Stage executed' } } stage('Unit Test Stage') { steps { sh "mvn -Dtest=MockitoExampleTest test" echo 'Unit Test Stage executed' } } stage('Master Stage'){ when{ branch 'master' } steps { echo 'run this stage only if its running on the master branch' } } stage('Conditional Stage') { when { ...

Jenkins Scripted Pipeline

Image
Sample Jenkins Scripted Pipeline node { stage "Git Pull" git "https://github.com/nishantautomationlabs/nal-junitmockito.git" echo "code pulled" stage "Run Declarative Pipeline" build "Declarative Pipeline" echo "Declarative Pipeline triggered" stage "print" for(int i = 0; i < 10; i++) { if(i % 2 == 0) { echo "Number " + i } } } Jenkins Configuration: Build History:

How to create your first Jenkins Job

Image
Creating your first Jenkins Job Prerequisite:  Jenkins is installed and configured, if you need any help doing so, refer the steps  here  and here . Navigate to your Jenkins dashboard by browsing  http://localhost:8080   Since we are going to create a Maven job, lets first install the maven integration plugin and a couple of other plugins which will help us with reports. Click on "Manage Jenkins" from the left pane and then click on "Manage Plugins" Click on "Available" tab and search for maven in the Filter text box. Select "Maven Integration" from the list of suggestions. Next, you can also select "TestNG Results" and "HTML publisher" plugin which we will use for publishing reports. Optional: You can also select "Green Balls" plugins if you don't like the blue color balls of maven and want to show it in Green color on build success. Once you are done selecting the plug...

How to Configure Jenkins and Create a Node

Image
Jenkins Configuration Prerequisite:  Jenkins installation is completed. If you have not setup your Jenkins yet, refer the steps here . Navigate to your Jenkins dashboard by browsing  http://localhost:8080   Click on Manage Jenkins from the left pane Next click on Global Tool Configuration Under  Global Tool Configuration, c lick on JDK installations, uncheck the install automatically checkbox and enter the Name as JDK and JAVA_HOME as the directory at which you have installed the JDK Scroll down, click on Maven installations and similarly enter the Maven Name and MAVEN_HOME values Click Apply or Save Go back to Manage Jenkins and click on "Configure System" Scroll down to E-mail Notification and click Advanced Go to the Gmail account you wish to use for sending emails from Jenkins, turn on the 2 step verification (if you don't have it on already) and generate an app-specific password for Jenkins. ...

Setup Jenkins on Ubuntu 16.04

Image
What is Jenkins? Jenkins is a self-contained, open source automation server which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software. Jenkins can be installed through native system packages, Docker, or even run standalone by any machine with a Java Runtime Environment (JRE) installed. Jenkins Installation Prerequisite: Java should be pre-installed on the machine. Add Jenkins key by running below command, you should get the output as OK.  wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add - Add the Debian package repository to the sources.list.  sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' Run update to use the added repository.  sudo apt-get update Now install Jenkins using apt-get.  sudo apt-get install jenkins Once the installation is completed, start Jenkins using systemctl.  ...