October 7, 2020 Jonny Steiner

Go From Code to Delivery with SeeTest and the Bamboo CI Server

Share this knowledge!

In today’s DevOps era, continuous integration and continuous delivery (CI/CD) is an important component of software development environments. Effectively managing your CI/CD pipeline is the key to fully leveraging test automation benefits. Bamboo CI Server is a popular Continuous Integration/Continuous Deployment (CI/CD) tool that enables you to easily automate your CI/CD tasks.

An Overview of a CI/CD Environment

In a traditional software development environment, applications development uses the following process.

  1. Software developers write the code.
  2. The code is uploaded into a central repository system (version control system) such as Github, and Apache Subversion.
  3. The code is downloaded from the VCS and the build process is performed to generate artifacts using build tools such as Maven, Gradle, and Ant.
  4. The artifacts are deployed into the testing environment and the QA teams run automated tests on the code.
  5. If the code contains errors, it is sent back to the developers.
  6. After the code successfully passes the test, it is deployed into the production environment.

In a DevOps CI/CD environment, this entire process is automated. To manage this automation pipeline, you need a CI/CD tool. Bamboo is a CI/CD tool that has become quite popular in recent times.

An Overview of Bamboo

Scott Farquhar and Mike Cannon-Brookes founded Atlassian in 2002. Bamboo CI Server is a continuous integration and continuous deployment tool developed by Atlassian in 2007. It is commercial software developed using the Java programming language. Installing Bamboo is a slightly complicated task as you have to install and configure multiple tools. You also need to have good knowledge of the CI/CD environment. However, once configured, the tool is easy to use. The GUI-based environment is user-friendly. Moreover, it offers extensive online documentation. It also has a huge and active community. Bamboo works on Windows, Linux, and Safari, and supports major browsers such as Chrome, Edge, Safari, and Firefox. It offers several plugins to integrate it with multiple platforms such as JIRA, Bit Bucket, Git branching workflows, and REST API.

Bamboo automates the entire CI/CD pipeline. When developers update the central code repository, the tool automatically downloads the code and performs the build process on it and creates artifacts. It then deploys these artifacts into the testing environment and initiates the test automation process. Bamboo CI Server will run the automated tests and check if the code is working fine. If there are errors, the developers will receive them. Else it will deploy to the production environment. You can create a plan and monitor and manage everything from a single dashboard. Seamless integration and collaboration between cross-functional teams is the key to fully leveraging the test automation benefits.

Installation

While installing Bamboo CI Server is a pretty simple task, the challenge lies in setting up the entire CICD pipeline. Here are the components required to set up your continuous integration and deployment pipeline and configure it to manage your test automation environment.

  1. Java Runtime environment
  2. IDE to run test scripts (Eclipse)
  3. Build tool (Gradle)
  4. Central Code Repository ( Github)
  5. Development Server for testing applications (Apache Tomcat)
  6. Selenium for Test Automation
  7. Bamboo Server

Step 1: Install Java and Configure Environment Variables

A basic requirement for any testing environment is a programming language. Visit this link to download Java.

Java SE 15 is the latest release. However, Bamboo supports only Java 1.8 and older versions. So, you need to search for an older version of Java. You can download Java 1.8 from this link: https://www.oracle.com/in/java/technologies/javase/javase-jdk8-downloads.html

  • After downloading the JDK file, double-click it to install Java on your machine.
  • After installing Java, you need to configure environment variables.
  • To do so, go to System -> Advanced System Settings -> Advanced -> Environment Variables
  • Add Java path to the System variables and User variables.

Step 2: Create a Github Repository

Developers write the code and upload it to a central code repository. So, create a free account in Github to upload your code.

https://github.com/join

Provide your details such as name, email, etc, and create a free account. After completing registration, confirm your email. After email verification is successfully done, you can start using the GitHub account.

Now, login to your GitHub account.

GitHub Bamboo CI Server

Click on the ‘new repository’ and provide a name to the repository. Now, you can add your code to that repository and use it for CICD purposes.

Step 3: Install Eclipse

To create and run java test programs, you need an IDE. Eclipse is a popular IDE for Java. Visit this link to download Eclipse:

https://www.eclipse.org/downloads/

Eclipse IDE 2020-09 is the latest release. However, the latest Eclipse version doesn’t support the Java 1.8 environment. So, you need to opt for an older version of Eclipse. You can go with Eclipse Luna.

Visit this link to download Eclipse Luna:

https://www.eclipse.org/luna/

After downloading the setup file, double-click, and install the software.

Step 4: Install a Build tool – Gradle

To automate the build process, install a build tool. Gradle is a popular build tool for Eclipse. To download Gradle, visit the following link:

https://gradle.org/install/

The latest Gradle version is Gradle 6.6.1

  • Download and save the Zip file on your machine.
  • Create a new directory in the C folder( Eg: C:\Gradle)
  • Unzip Gradle files into the Gradle folder
  • Add the Gradle bin folder path to the environment variables.

Step 5: Create a Java project in Eclipse

Now, open Eclipse and click on File -> New -> Java project.

Java Project Eclipse - Bamboo CI Server

Provide the project name (eg: ExperitestProject) and click Finish. Now, right-click on the project and select New -> Class.

java class Bamboo CI Server

Now, add the following code to the Java class file. The final string will ask for an access key. If you need help you can find more information about access keys here.

package ExperitestPackage;

import org.openqa.selenium.*;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.net.URL;

public class ExperitestSearch {

private static final String ACCESS_KEY = "Enter your token here";
    private RemoteWebDriver driver;
    private URL url;
    private DesiredCapabilities dc = new DesiredCapabilities();

    @BeforeMethod
    public void setUp() throws Exception {

        url = new URL("https://cloud.seetest.io/wd/hub");
        dc.setCapability(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
                dc.setCapability(CapabilityType.PLATFORM, Platform.ANY);
        dc.setCapability("accessKey", ACCESS_KEY);
        dc.setCapability("testName", "Quick Start Chrome Browser Demo");
        driver = new RemoteWebDriver(url, dc);
    }

    @Test
    public void browserTestGoogleSearch() {
        driver.get("https://www.google.com");
        new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.name("q")));
        WebElement searchBar = driver.findElement(By.name("q"));
        searchBar.click();
        searchBar.sendKeys("Experitest");
        searchBar.sendKeys(Keys.ENTER);
    }

    @AfterMethod
    public void tearDown() {
        System.out.println("Report URL: "+ driver.getCapabilities().getCapability("reportUrl"));
        driver.quit();
    }
}

Step 6: Install Selenium for Test Automation

To automate browsers, you need Selenium. Visit this link to download Selenium:

https://www.selenium.dev/downloads/

The latest stable version is 3.141.59. It is available as a jar file. Download the jar file and save it on your machine.

To add Selenium to your Java project, open Eclipse and right-click on your Java project.

Click on the build path.

Configure Build Path Bamboo CI Server

Click on Library and click on Add External JARs.

Java Build Path

Provide the Selenium path and click Apply and Close. That’s it. Now, Selenium is available for your Java project.

Step 7: Upload Code to Github Repository

Run the Java project in Eclipse. It shows that the test has passed.

Java Project Eclipse

Now, you need to commit this code to the Github repository. To do so, right-click on the project -> Team -> Share project.

Share Project

On the next screen, select the project and click on Finish.

Configure Git Repository Bamboo CI Server

Select the repository and the project and click finish. You need to enter the username and password of your GitHub account.

Right-click on your project and click on Team. Now, you can see a menu with different options such as commit, pull, and push. etc. It means the repository is successfully connected with Eclipse.

Team

Now, you can write code in Eclipse and directly push it into the Github repository so that Bamboo can pull it from the Git repository.

Step 8: Install a Test Environment Server (Apache Tomcat)

To download and install Apache Tomcat, visit this link:

https://tomcat.apache.org/download-80.cgi

Mirrors Bamboo CI Server

Choose the Windows Server installer and download the file. After completing download, double-click the file to begin the installation process.

Apache Tomcat Setup Bamboo CI Server

Click Next.

Apache License

Click ‘I Agree’ to accept the license agreement.

tomcat components

Choose the components you want to install and click next.

Tomcat Configuration

On the Configuration screen, enter the server name, port and choose a username and password for Administration login. Click next. On the next screen, provide the Java path and click next.

Java Virtual Machine

Choose the installation location and click on Install.

install location

The installation process begins.

Tomcat Installing

After completing installation, you can start using the Tomcat server.

Tomcat complete setup

To check if Tomcat installed and runs, open a browser and type the following command: http://localhost:8080

Tomcat 8.5.58

You can see the Tomcat server page. It means Tomcat is properly installed and is running on your machine.

Step 9: Connect Eclipse to Tomcat

If you want to push the code from Eclipse to Tomcat web containers, you need to tell Eclipse about the Tomcat server. So, open Eclipse and click on help.

eclipse connect to Tomcat Bamboo CI Server

When the Eclipse Marketplace window opens up, type ‘tomcat’ in the search box and click on ‘Go’.

Eclipse marketplace

In the search results, you can see the Eclipse Tomcat plugin. Click on install.

eclipse tomcat

Accept the license agreement on the next screen. The plugin gets installed.

Eclipse Tomcat Install

When the plugin is installed, you can see the Tomcat menu in Eclipse.

After the plugin is installed, you need to configure Tomcat in Eclipse. To do so, Click on Windows -> Preferences

Preferences Bamboo CI Server

In the preferences windows, click on Tomcat in the left menu. On the right side, select the Tomcat version and provide the Home directory for Tomcat. This is where all your files will be stored.

preferences

Click on the Advanced tab and add the projects you want to work with Tomcat. The selected Java projects will be added to Tomcat’s classpath.

preferences

To start Tomcat server, Open Eclipse -> Tomcat -> Start Tomcat.

Step 10: Install Bamboo

Visit the following link to download Bamboo continuous integration server:

https://confluence.atlassian.com/bamboo/installing-bamboo-on-windows-289276813.html

install bamboo CI Server

Click on the download site link and accept the license agreement on the pop-up window.

Download Bamboo CI Server

Now, double-click the setup file to begin the installation procedure.

Install

Click on next. On the next screen, choose the destination folder and click next.

Set up

On the next screen, choose the Bamboo Home directory. Make sure not to place this home directory in windows security controlled folders.

click next

Click next so that the installer starts installing the package. Click Finish when the process is completed.

complete installation

Now, open the Bamboo application. You can run it from windows or you can use your command prompt to do so. Open the Command Prompt and navigate to the bin folder. Type the following command:

  • Start-bamboo.bat

star in console Bamboo CI Server

Now, Bamboo Server has started. To access the application, open your browser, and type the following command: http://localhost:8085

It will open the Bamboo wizard.

Bamboo CI Server

You need to enter a license key. To obtain a license key, register for a free account on the Atlassian website.

Open this link:

https://id.atlassian.com/login?application=mac&continue=https://my.atlassian.com

Login with your Gmail, Microsoft, or Apple account.

atlassian login

When you log in to the Atlassian site, you can generate the license key.

new liscense

Select the Product (bamboo), enter the name of your organization and provide the server ID. Check the Bamboo wizard page to get the server ID.

Welcome to Bamboo CI Server

After entering the server id, click on ‘Generate key’. Atlassian will provide you with a trial license key.

License key

Copy the license key and paste it in the Bamboo wizard setup page and then click Express installation.

bamboo wizard page

The tool will start creating a server instance.

Bamboo new insance

On the next screen, enter the admin user details to manage the server.

express installation

Click on finish and it will finalize the setup and take you to the Build dashboard to create your first build plan.

Now, the Bamboo CI/CD tool is ready for use.

Working with Bamboo CI Server

To get started with the tool, go to the Build dashboard and click on ‘Create your first Build plan’.

Get started Bamboo CI Serer

Enter the details about the project, project key, project description, plan details, etc.

con figure plan

You also need to link a repository to this plan. So, select the ‘Link new repository’ option and provide your Git repository link as well as the username and the token. You can generate a personal access token by logging into your Github account.

  • Go to Settings -> Developer settings -> personal access tokens.
  • Click on generate new token.

Provide the username and token in the build plan page and save it. Now, open the build plan and click on the Run button that is located on the top right corner.

Bamboo CI Server Configure

Bamboo will run the build plan. You can check the details of the build process to see how it went.

Build Details

Create a Deployment Project

Open the Bamboo dashboard and click on the Deployment tab and choose ‘All Deployment projects’.

Bamboo CI Serve Deployment Plan

Now, click on to create my first deployment project.

first deployment project

Enter the project name, description. Now, you need to link this deployment project to a build plan so that Bamboo CI Server will take the shared artifacts from the build plan and deploy them to the test environment. After entering all the details, click on Create deployment project.

Now, you need to create a deployment environment. To do so, open your deployment plan.

deployment for experitest

Enter the name of the environment and provide a description and click on Create.

deployment setup

On the next screen, click on setup tasks.

setup tasks

You need to specify a task that will make the deployment project a success. Here, we want to download artifacts from our code and upload them to the QA server. So, click on Artifact download.

artifacts download

Enter the task description and select the artifact you want to download. Provide the destination path and click on save.

Open the deployment project and click on ‘Add task’. Enter the task description, provide Tomcat URL, administration login, and details. and click on save.

deploy tomcatNow, you can see that all tasks are marked with green.

all green

Now, open your build plan and click on Run. The build process is done.

process complete

It shows that the build was successful. Now click on Create release. Provide a release name and click on save. So, every release will be named Experitest-1, Experitest-2, Experitest-3.

Release Versioning

Go back to the Deployment plan and click on Deploy.

qa server

Select the Build result you want to deploy and click on Start deployment. The latest one is deployed to the Test environment.

You can click on the Plan summary to see how many builds passed, how many failed, how many deployments are made etc.

deployments

Bamboo CI Server comes with a nice reporting tool. Click on Reports and create customized reports and statistics.

custom Reports Bamboo CI Server

The dashboard is intuitive and user-friendly. You can easily create a plan, add tasks, run them, and generate reports to see how everything went.

Summary

Bamboo CI Server is a powerful tool to automate and manage your CI/CD test environments. Though the setup is complex initially, once everything is properly configured it gets easier. The tool offers clear visibility into the entire continuous integration and deployment pipeline. So, you can focus more on writing code rather than managing your test environment. Bamboo supports only Java 1.8 and older versions. So, you need to install Java 1.8 and make sure that other tools are compatible with that version.

Guy ArieliCTO

Share this knowledge!