Continuous delivery aims to reduce development costs through high-level automation, speed up deployment processes, increase the quality of processes and be more flexible and responsive to customer requirements earlier on in the process. (Our video session offers a detailed introduction to the concept.)
Part of this article addresses how this is done in practice. We will configure Atlassian's CI server Bamboo to install a simple Java web application on a Tomcat application server at the touch of a button.
While managing our process, we will follow the "fail fast" approach and choose a method consisting of the following four phases.
Compiling: We compile the source text here, add resources and generate the necessary artifacts for testing and running our application.
Unit tests: In this phase, isolated tests are run with fast turnaround times. A fail in this phase prevents the time and resource intensive execution of the next phase.
Functional/integration tests: In this phase, more complex tests with longer run-times and higher resource costs are run. For example, tests for component interaction.
Deployment: In this final phase, the application is installed on a defined target system.
Stages vs. jobs vs. tasks: Stages let us create logical units for performing jobs. Jobs within a stage can be completed in parallel distributed over many agents. On the other hand, tasks within a job are always processed in a row by an agent. (You can find additional information in the Bamboo documentation.)
Creating a new build plan in Bamboo
A build plan forms the basis of these processes. First, we will add the necessary stages.
We will create three stages: Unit Test, Integration Test and Package Application.
Stage: Unit Test. In this stage, high-speed, isolated unit tests are performed. Terminating our build process early on helps save resources. We add a job with the same name here. The first task from the new job is to first check the source text from a Git repository of a connected Stash server. Then we insert a Maven task that triggers the test to be run using
mvn clean test.
Artifacts can be divided between jobs, build plans and, of course, deployment projects, and allow workflow events to be delivered to the Bamboo server (see the Bamboo documentation). Here, we save the checked project files as a Bamboo artifact with the name Project Sources, so that in the following stages and jobs, you don't have to download the data again. Artifacts from a job are available in the tab with the same name (Artifacts).
Stage: Integration Test. More complex tests with longer run-times and greater resource requirements are run here. In our example, the stage is left empty. It is only used for illustrating a realistic workflow.
Stage: Package Application. At this point, we generate a web application and compress it as a WAR file that can be used for deployment. At this stage, we use the sources again that we provided as an artifact in the first stage.
We can integrate this data using a task for the artifact download:
Finally, we add a Maven task again to build the application using
mvn clean package:
Since we want to provide the built WAR file for deployment, we define an artifact here again with the name Application War File:
Now we can start creating a new deployment project.
Configuring a new deployment
Create a deployment project
When creating a new deployment project, we first give our project a name and select the corresponding build plan and branch for the deployment.
Create a new environment
If the application should be imported to different servers (for example, staging, production, preview, test, etc.), we can differentiate between these by configuring deployment environments (Environments). We create a new environment called Preview:
Create deployment tasks
Here, we define the individual steps necessary for importing our WAR file to the application server:
Clean working directory: This step (Clean working directory) is already activated by default. We retain this step in order to always start with a clean working directory.
Downloading the WAR file artifact: In the next task, we instruct Bamboo to prepare the WAR file we exported as an artifact in the build plan for deployment by adding an Artifact Download Task:
Uninstalling the application on the Tomcat server: We remove the application from the specified Tomcat server using an Undeploy Tomcat Application task.
Installing the application on the Tomcat server: Now we install the current application using the WAR file and a Deploy Tomcat Application task on the dedicated Tomcat server.
Executing a deployment
Now we are ready to run a deployment with the touch of a button. The only condition is that the build plan was successfully run. Let's start! We select the Preview environment and click Deployment:
In the next step, a new release can be created from the results of our build plan run:
Start Deployment initiates the process and switches to log view where we can see the log output of individual tasks and processes. Subsequently, a success report like the following is issued:
The release overview provides details on the release:
Optionally, a release can now be approved. This information can then be used, for example, on additional deployments (automated or manually) - for instance, on production or customer systems.
Your partner for individual software projects
Are you already planning a specific software project? Or are there certain processes at your company that have long given you headaches? Is a system or interface slowing down your employees or customers? Then talk to us about it. We look forward to developing a custom solution with you - with the highest standards of quality and complete cost control. We emphasize expandability, performance, scalability, platform independence, and testability in our work. We create custom high-end software solutions that can later be expanded and modified.
Read in German.