This guide will help you introduce pipeline-based continuous delivery to your development project. Continuous integration & delivery is not only a flavor of the month – it’s an industry standard. If you want to catch up with the hottest IT trends, this guide is for you. Also, in case you are already familiar with the continuous approach, you can simply skip the first part and move on to the pipelines section.
Objectives of this guide
With this guide you’ll be able to:
- Understand the concept of continuous delivery
- Understand the notion “delivery pipeline” and find out how to use it to automate your work
- Grasp best practices and analyze sample development workflow
Why should you care about Continuous Delivery
The term continuous delivery is still a bit confusing, the more it’s often replaced by the notion of continuous deployment and mentioned in the context of continuous development. All the phrases stem from the agile approach to development, where the cycle time is cut down as much as possible. Why? The faster the product moves to the next stage of the development process, the faster you receive feedback and will be able to deliver another, better version – see graphics below.
The advantages of shorter cycle time, when every change in the code becomes a deployment, are obvious and include:
- Delivering new features faster
- Receiving feedback in an instant
- Improving quality
- Reducing the risk of unsuccessful implementation of the change
- Saving time required to perform tasks manually
To benefit from continuous approach to development, you have to automate your work as much as possible. However, the implementation of the CD processes can be time and resource-consuming. In the next part of this guide we are going to show you how to easily implement the automated continuous approach in large and small projects using Buddy and its pipelines.
“The most powerful tool we have as developers is automation.” – Scott Hanselman
General information concerning pipelines
What is a pipeline actually? The idea is pretty straightforward:
A pipeline is a set of actions, executed by a Git push or by a developer in a specific order that delivers an app or website from a Git repository to wherever a developer wants.
The pipeline resembles a little bit a production line, where some items are assembled, examined if they meet the quality standards, wrapped and packed in boxes and sent to the customers. In software development we simply skip fancy wrapping paper and decorative boxes and do our job – deliver software in a continuous manner.
Industrial production lines vary depending on the nature of the business. In case of software delivery it’s exactly the same – they will be different for every project and every team, depending on the technology and the approach used. However, every pipeline has the same major sections:
- Build and Integrate
All the above actions should be performed automatically and you can easily achieve this with Buddy and the pipelines.
Pipelines in Buddy
Buddy offers the possibility to design continuous delivery pipelines tailored to individual needs. It supports all the general stages mentioned in the previous section. And actually Buddy can do much more. Let’s take a look at the functions.
The main component in Buddy is a project. It consists of two main elements: a Git repository and a set of pipelines, defining when and how the source code from the repository will be processed (compiled, tested, prepared for deployment) and delivered to a given server.
When you log into Buddy for the first time, you have to add new project and connect it to the Git repository you are going to automate (GitHub or BitBucket) or push your Git repository to Buddy (you can host your Git project in Buddy without any external provider).
Let’s assume you have already created your project and connected it with the repository. Now you are ready to add the first pipeline.
Creating a Pipeline
We are going to create a pipeline that will:
- Build the application on every push to master branch
- Deliver the application files to server
- Restart the application on server
- Notify you if any of the above actions fails
Go to Pipelines screen and click Add a new pipeline.
Enter the pipeline name (MyFirstPipeline). Select trigger mode On every push and select the branch Master. Then, click Add a new pipeline. Buddy will create MyFirstPipeline and display the set of available actions.
You can select other pipeline trigger modes (Recurrently or Manual) – see our help.
You can select other branch options. – see our help.
Now we are going to add actions (build application, deliver to server, restart application) to MyFirstPipeline.
1st action: Pipeline, I want you to build a Node.js application in a Docker Container
Usually your code requires compilation. Buddy allows you to build applications in Docker containers, which are more or less similar to virtual machines. The user defines what tool would be used during building the application and what commands would be executed.
In our sample pipeline we shall build a Node.js application with Gulp. To do this, pick a pre-defined action for Node.js. All we need to do now is enter the commands that will build the application, pick the version of Node and enter the commands that will install Gulp.
2nd action: Pipeline, now I want you to deploy what you’ve just built
We have just added the action that will build the application. Upon completion of this step, we need to upload the application to server. This can be performed by another action from Buddy’s actions set. You may chose from a variety of protocols like FTP/FTPS/SFTP or upload you application to Elastic Beanstalk, S3, Google Cloud Engine and so on.
3rd action: Pipeline, restart my app on the server. Quick!
Very often you will need to perform certain operations on the server where you deployed your application, e.g. database update or service restart. All you need to do in Buddy is adding an SSH action, where you define the connection data and operations you want to perform. In our example we will connect with the server and restart the application.
Next actions: Turn on and off maintenance mode
Of course you should inform your users that the service is offline for maintenance instead of leaving them with a website churning out downtime errors. Thus, we are going to add two more SSH actions to our pipeline that will take care of notifying them the solution is currently unavailable:
The first one will switch on maintenance break screen before delivering the application to server
The second one will switch off maintenance break screen when application restart is complete
And this is how your final pipeline should look like:
Run, Pipeline, Run!
That’s it – your pipeline is ready. It will automatically build the application, deliver it to server and restart the application, notifying you if any of those operations fails. Let’s check how it works.
When something goes wrong your Pipeline got you covered
We defined the pipeline, which on every push to Master branch builds the application, uploads it to server and restarts application on the server. But what if any of these actions fails, for example if the upload is unsuccessful? The user should be notified. In Buddy all you need to do is adding a notification action in On failure section, where you can pick the appropriate option (e-mail, text message or Slack).
Wait, there could be more
When you open the Pipelines screen, you will find MyFirstPipeline on the list, together with other pipelines you defined. For each project you can define an unlimited number of pipelines. Usually they will include one pipeline that builds the application on every push and the pipeline that delivers the application to production server.
The Pipelines screen also provides the information on when the pipeline was run, for which branch deploy is executed and if the server is up-to-date with the reference server. Here you can also check the pipelines currently in progress and the ones that failed since one of the actions in the pipeline failed.
We are done – we learned how to create pipelines that would allow continuous delivery approach in our project. It will help you save time and deliver software in a more efficient way.
This is just a brief summary on what Buddy offers regarding pipelines. If you are interested in our solution, you can read more about Buddy in other guides.
Thank you for reading!