Jenkins CatLight

CatLight is a status notifier. Jenkins is a CI tool. Put the two together and you get Jenkins CatLight. CatLight allows us to listen for updates from Jenkins, which are then cleverly posted to the user.

Jenkins CatLight

Navigate to https://catlight.io/ and download the client. Once downloaded, install and open the app. You should see a screen similar to this:
Jenkins catlight

Select Jenkins and you should then have a screen similar to this:
jenkins catlight

Populate the ‘Server URL’ field with the host value of Jenkins, credentials and select next.
jenkins cli

Once done, you should see a list of all your Jenkins jobs listed.
jenkins catlight

Status Update

With the setup now complete, CatLight should now start to publish status changes from Jenkins.
jenkins catlight

Conclusion

CatLight combined with Jenkins is a great tool to aid developers in staying more up to date with builds from Jenkins.

Jenkins CLI

Jenkins CLI, your one stop shop for a ‘quicky’ with Jenkins.

Jenkins is an amazing CI tool which allows us to run tasks via jobs. It allows us to runs automated jobs over time. This allows developers to understand how stable their code base is. Along side this, Jenkins is one of the most popular CI tools around today. With this said, what role does Jenkins CLI play?

Jenkins CLI Setup

Great, let’s try to setup Jenkins CLI locally first. This post assume that you have already installed Jenkins on your machine. If not then you may want to firstly install Jenkins on your machine.

Once you have Jenkins up and running, navigate to the Jenkins Dashboard. Once there, we need to firstly setup a few quick things.

Configure Global Setting
For the purpose of this post, let’s allow any user to be able to do anything. Ensure the ‘Allow anyone to do anything’ radio button is selected.
jenkins cli

User Passphrase
You will most likely need to know what your passphrase is for the purpose of this post. To get this, navigate to your user name in the header of Jenkins and select the ‘Configure’ option. Once on the ‘User Configuration’ page, scroll down until you see the value of ‘SSH Public Key’. Make a note of the key.
jenkins cli

Jenkins CLI
Now that we have our passphrase and a given user is able to do anything, let’s try to access the CLI. Navigate back to the ‘Manage Jenkins’ and select the ‘Jenkins CLI’ option.
jenkins cli

In order to run Jenkins CLI, we need to download then ‘jenkins-cli.war’ file. Fortunately for us, the link is provided in the Jenkins CLI page. Download the war file and navigate to the folder where you downloaded it. I would suggest that you place the ‘jenkins-cli.war’ file in the same directory as your ‘jenkins.war’ file.

Running Jenkins CLI
With the file now downloaded, let’s try to run it. War files as just another type of Java file, this means we can simply run it using java commands. To run the file, we provide commands in the following format.

Java -jar Jenkins-cli.jar -s [JENKINSHOST] [COMMAND]

Let’s try to print all the help commands for Jenkins CLI. Try running the following below:

Java -jar Jenkins-cli.jar -s http://localhost:8080/ help

This should now return a list of all the available help commands below:
jenkins cli

Jenkins CLI Commands

Now that you are able to run commands in Jenkins CLI, let’s try to run some of the commands below:

Restart Jenkins

Java -jar Jenkins-cli.jar -s http://localhost:8080/ restart

List All Jenkins Jobs

Java -jar Jenkins-cli.jar -s http://localhost:8080/ list-jobs

Run A Jenkins Build

Java -jar Jenkins-cli.jar -s http://localhost:8080/ build <job-name>

Conclusion

Jenkins CLI is a quick way of accessing the same builds, the same jobs and services but much quicker. As opposed to traversing the GUI of Jenkins, you can instead perform the same actions by some simple commands.

Jenkins Cron Setup Tutorial

We will look at Jenkins Cron scheduling in this blog entry.

Jenkins Cron Scheduling

First of all what is Cron? Cron is a Unix based scheduling system that helps us define a time stamp which can represent time of day, time of year, day of month etc.

In Jenkins the time is split into 5 sections:

Minutes [0-59]
Hour [0-23]
Day of Month [1-31]
Month of Year [1-12]
Day of Week [0-7] (both 0 and 7 present Sunday)

Each number above represent their given range of value and in the event you want to use any value then you use *. So in the event you want to present 8:30am for any given day of the year then you can do this like so:

30 8 * * *

Setting a Cron Schedule in a Jenkins Jobs

Navigate to Jenkins and configure an existing project. Now under the build trigger section you should see a Build on Schedule option. Tick it and this will open a text field box. Inside the text field box enter the value of the time you want to run but express the time in Cron format.

And there you go, you can now automatically run your Jenkins job using a Cron time.

Follow the video tutorial below to see a more detailed view of this blog.

Video Tutorial on YouTube

jenkins cron
Direct Video Link

Jenkins Cucumber Tutorial

Jenkins Cucumber Tutorial

Jenkins Cucumber Tutorial, this in blog entry we will look at writing a simple Cucumber test and then running it via Maven. Once we are able to run the test via Maven we will be able to run it via Jenkins.

Feature File:
The feature file below will be used to simple navigate to the QAShahin YouTube page and then assert on the fact that we are on the correct YouTube page.

Feature: Simple feature
 
Scenario: Go to QA Shahin YouTube Page
Given I go to "QASHAHIN"
Then I should be on "QAShahin" youtube page

Step Definition Class:
The Java class below will be used to identify each step definition for each of the test steps for.

public class StepDefinition {
 
WebDriver driver;
 
@Given("^I go to \"([^\"]*)\"$")
public void goTo(String args) {
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
driver = new ChromeDriver();
driver.navigate().to("https://www.youtube.com/user/GlassBoxt");
}
 
@Then("^I should be on \"([^\"]*)\" youtube page$")
public void shouldBeOnYouTubePage(String page) {
Assert.assertTrue(driver.getTitle().contains(page));
driver.close();
}
 
}

Test Runner Class:
The code below is used to actually identify which feature files to run but through JUnit.

@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/java")
public class RunCucumberTest{}

Now let’s try to run ‘mvn test’ from the command line.

Assuming you were able to run Cucumber feature file from the command line you should now be able to run feature files from Jenkins by just creating a simple Jenkins job.

Follow the video tutorial below to see a more detailed view of this blog.

Video Tutorial on YouTube

Jenkins Cucumber Tutorial
Direct Video Link

Jenkins Selenium Tutorial

Jenkins Selenium Tutorial for beginners. In this video we will go through setting up a job in Jenkins and we will do this by first writing a simple Selenium JUnit test and then running it via Jenkins.

Jenkins Selenium Tutorial

Let’s begin by writing a simple Selenium JUnit test.

Before writing the script we will need to download the Chrome Driver which can be found at the URL below:

https://sites.google.com/a/chromium.org/chromedriver/downloads

You may also need to import your selenium dependency if your using Maven:

http://docs.seleniumhq.org/download/maven.jsp

Here is a simple code for a quick Selenium JUnit test script:

public class SampleTest {
 
private WebDriver driver;
 
@Before
public void setUp() {
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
driver = new ChromeDriver();
}
 
@After
public void tearDown() {
driver.quit();
}
 
@Test
public void shouldLoadQAShahinYouTubePage() {
driver.navigate().to("https://www.youtube.com/user/GlassBoxt");
String title = driver.getTitle();
assertTrue(title.contains("QAShahin"));
}
 
}

Once you have the above script let’s make sure that we are able to run it via maven. Lets do this by opening a terminal and typing in ‘mvn test’. Now go to Jenkins and create a simple job as the previous blog and simple pass the ‘test’ maven goal and supply the location to the pom.xml file.

For a more detailed view of this blog you can follow the YouTube video below.

Video Tutorial on YouTube

Jenkins Selenium Tutorial

Direct Video Link

Jenkins Installation Maven Test

Jenkins Installation is an important concept as this will allow you to run Jenkins.

Jenkins Installation Maven Test

In this blog post we will look at Jenkins Installation and run a Maven test as part of it.

In order to install Jenkins we first need to ensure we have the following:

* Installed Java (http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html)
* Installed Maven (https://maven.apache.org/download.cgi)
* Installed Jenkins (https://jenkins.io/) and download the latest war file.

Once you have downloaded the above make sure to set the relevant environments variables in your windows system.

You will need to set the following environment variables:

* JAVA_HOME = path to your Java root directory installation
* MAVEN_HOME = path to your Maven root directory installation
* M2_HOME = path to your Maven root directory installation

Once done you will also need to add the above three to your path variable:

* path =  + ";%JAVA_HOME%\bin;;%MAVEN_HOME%\bin;;%M2_HOME%\bin;"

Once the above is done, open a terminal and type in ‘java -version’ and this should give you a version of Java. Do the same for ‘mvn -version’ and this should return a version for Maven.

With the above done now run the following:

java -jar followed by path to war file

This will start Jenkins, now navigate to localhost:8080 and you should see Jenkins up and running.

Once the above is done simply create a simple Maven project in your choice of IDE and create a new project in Jenkins and run the ‘test’ goal in Maven by also supplying the location to the pom file and that should be it.

If any of the above is confusing then I cover the same tutorial in more detail in my YouTube video link below.

Video Tutorial on YouTube

Jenkins Installation
Direct Video Link