Sunday, October 23, 2016

Getting Started With Concourse CI - Part 2

Introduction

Now that you have a Concourse CI test instance running from the last post, let's use it.  In this post, we will go over uploading a "Hello World" pipeline.  Also, since this product is always improving, we will go over the steps to upgrade this test instance.

Getting Familiar with Concourse

There is a great example of setting up a Hello World pipeline on the Concourse documentation site.  I am going to go through some of the common commands they reference and explain how to do some of these steps if you are using a private Docker repository.  You can review my blog series on Pivotal Cloud Foundry and Docker to see the references of using a private Docker repository.

Fly CLI

The way you interact with Concourse is through the Fly cli.  The easiest way to download the version you need is to go to your Concourse test instance, http://concourse-hostname:8080.  It will have a link to download the correct version for your operating system.  After you download the executable, make sure to place the file some where in your operating system's PATH or update your PATH to include the location of this executable.

Once you have the cli in your path, we need to setup the Concourse target and login.  Referencing the test instance that you stood up, you will enter in the following.

[user@linux_prompt]$ fly -t concourse-test login -c http://concourse-hostname:8080

The command will return with a prompt asking for a username and password.  You will just need to enter the username and password you setup during your Concourse web service startup script.  After you successfully logged in, you have created a Concourse target called concourse-test.  You can name the target whatever you want, but you will just need to remember the target name because that name is how you interact with your instance.  If you forget the target name, you can run the following command to list all of the targets you setup.

[user@linux_prompt]$ fly targets

Creating Your First Pipeline

Now that you have successfully logged into your instance of Concourse, let's create a pipeline. I have modified the Concourse sample pipeline below to include a private Docker registry.

I have added the insecure_registries entry into the script. This will ignore certificate errors when the registry has certificates signed by a private Certificate Authority.  If you are not using a private Docker registry, you can use the example on the Concourse documentation site.

Once you have placed the text of that script into a file called hello.yml, you can upload the pipeline to Concourse with the following command.

[user@linux_prompt]$ fly -t concourse-test set-pipeline -p hello-world -c hello.yml
[user@linux_prompt]$ fly -t concourse-test unpause-pipeline -p hello-world

The pipeline will now be loaded into Concourse as well as started.  It will have downloaded the Ubuntu image from the Docker repo you specified and printed out "Hello, world!".  Congratulations, you now have tested your Concourse instance with your first pipeline.

Upgrading Concourse

To keep up to date with the latest enhancements, you will want to upgrade Concourse to the latest version.  If you followed my guide in the last post, it is really easy.  You can download the latest version from the Concourse downloads page.  After you have downloaded the latest binary, you will need to SCP the file to the server.  When it is there, just run through these steps.
  1. Stop the Concourse service: concourse-service stop
  2. Rename the old binary: mv /opt/concourse/bin/concourse /opt/concourse/bin/concourse.old
  3. Move the upgraded binary to the /opt/concourse/bin folder
  4. Start the Concourse service: concourse-service start
It is as easy as that.  You will want to have a copy of the old binary in case the upgraded one does not work.  

Now that Concourse is updated, you will see that there is a new directory inside of your Concourse worker directory.  In this example, the worker directory is located /opt/concourse/worker.  This new directory will be named the version of Concourse you upgraded to.  

Another task you have to do now that Concourse is upgraded is to upgrade your Fly cli.  To update your cli, run the following command.

[user@linux_prompt]$ fly -t concourse-test sync

This will download the version of the cli to match the upgraded version of Concourse.

Summary

This post just scratched the surface of what Concourse can do.  Hopefully, you have been pointed in the right direction on using this tool.  The biggest benefit I have seen using this tool has been writing pipelines as code.  No longer do I have to click through multiple screens and option boxes to configure my pipeline.  Also now you can source control your pipelines to keep a versioning history of them.

~RRRII

4 comments:

  1. Nowadays the new era of this modern civilization is turning their heads towards cloud and the department which is most interested is the engineering department, all of the engineers would appreciate this post.

    ReplyDelete
  2. This tutorial regarding concourse was much needed.As so many of us are getting enrolled in concourse crash courses so we need a guidance on it too.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Thank you for sharing very informative and creative content.This content is very useful best way to extent the knowledge of
    piping design course in chennai


    bim course In chennai

    ReplyDelete