Using Atlassian Bamboo

The last continuous integration tool that we are going to configure is Atlassian Bamboo. Bamboo is a commercial continuous integration server. There is a 30-day evaluation license available from the Atlassian website. We will discuss how to configure Bamboo to use Gradle as a build tool for our Java project.

We can install Bamboo on our local computer. We will first need to download the installation package from the Bamboo website. We can choose native installers for Mac OS X, Windows, and Linux. Alternatively, we can simply download a packaged version and unzip it in a directory on our computer. Finally, we can download a WAR file and deploy it to a web container.

Defining a plan

Bamboo has no Gradle runner or plugin, but we can define a build plan and add the so-called script task. A script task can run any script as part of the build plan. To make sure that Bamboo can build our Java project, we must add the Gradle Wrapper scripts to the project.

We will run the wrapper task in our local Java project directory. We now have the gradlew and gradlew.bat script files. Also, the gradle directory is created with the configuration for the Gradle Wrapper. We add the directory and files to our Git repository, as follows:

$ git add .
$ git commit -m "Add Gradle wrapper output."

We are now ready to create a new build plan in Bamboo:

  1. We will start a web browser and open http://localhost:8085/. After we have logged in to Bamboo, we will select the Create Plan link. We will go to a new page, where we can set the properties of the build plan:

    Defining a plan

    Creating a new plan in Bamboo

  2. We must define a project name in the Project name field. Bamboo also expects a short identifier in uppercase characters as the project key in the Project Key field. The plan that is part of the project also has a name and key; we fill the Plan name and Plan key fields. We can set a short description in the Plan description field.
  3. In the Source Repositories section, we can define the Git repository location for our project.
  4. Finally, in the Build Strategy section, we will set the value of the Build Strategy drop-down box to Manual. This means that we have to manually start the build via the run action in the Bamboo user interface.
  5. We will click on the Configure Tasks button to add tasks to our plan. A task contains some logic that we want to execute as part of the plan:

    Defining a plan

    Adding a new task to the plan

  6. The first task is automatically added and it is responsible to check the source code of the Git repository. We will click on the Add task button to create a new task:

    Defining a plan

    Searching for script task

  7. A dialog window will appear, where we will select the Script task from the Builder section. With this task, we can configure the Gradle Wrapper scripts to be executed.
  8. We will return to the tasks window and we fill in the fields under the Script configuration:

    Defining a plan

    Configuring the script task

  9. We fill a description in the Task description field. Script location must be set to File instead of Inline. The Script file field has the location of the gradlew or gradlew.bat script that we want invoked.
  10. In the Argument field, we will pass the arguments to the gradlew script. We want to invoke the build task, so we set the value to build.
  11. We are ready to click on the Save button to save our script task configuration. The task is added to the list of tasks, as shown in the following screenshot:

    Defining a plan

    Configuration for the script task to run Gradle

  12. We can enable the plan in the Enable this Plan? section by checking the Yes please! checkbox. Next, we will click on the Create button to finish the configuration and save the plan in Bamboo.

    Defining a plan

    Overview of plan

Running the build plan

We are now ready to run the build:

  1. Click on the Run button at the top-right side of the page. While the build is running, we can see some of the log output. After the build is finished, we can see the results.
  2. We also want to add the project artifacts to our plan, and the test results as well. Therefore, we will select the Configure plan option from the Actions menu:

    Running the build plan

    Build results after running the plan

  3. We will then go to the Artifacts tab page and click on the Create definition button to add a new artifact definition:

    Running the build plan

    Defining artifacts for the plan

  4. We will see a dialog window and we can define Name, Location, and Copy Pattern of the artifacts here:

    Running the build plan

    Configuration for artifacts

  5. We fill artifacts in the Name field and build/libs in the Location field. The Copy pattern field is filled with the *.jar value to include all JAR files. We then click on the Create button to finish the configuration of the artifacts.
  6. Next, we will select the Tasks tab page and click on the Add task button to create a new task.

    Running the build plan

    Searching for task to publish test results

  7. In the dialog window with Tasks types, we will select JUnit Parser from the Tests section. Bamboo shows the configuration fields for this task:

    Running the build plan

    Configuration for test results task

  8. We will then set Task description with the Test results value. In the Specify custom results directories field, we will set the build/test-results/*.xml pattern.
  9. We are now ready to run our plan again; but this time, we have the test results:

    Running the build plan

    Summary of build results

  10. We will click on the Artifacts tab and see that the plan has produced artifacts:

    Running the build plan

    Overview of artifacts for the plan

  11. If we click on the artifacts link, we are taken to a page where we can download each artifact JAR file, as shown in the following screenshot:

    Running the build plan

    Links for downloading artifacts

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.104.242