Concourse CI is a Continious Integration Platform. Concourse enables you to construct pipelines with a yaml configuration that can consist out of 3 core concepts, tasks, resources, and jobs that compose them. For more information about this have a look at their docs
What will we be doing today
We will setup a Concourse CI Server v6.7.6 (web and worker) on Ubuntu 20.04 and run the traditional Hello, World pipeline
Create SystemD Unit Files, first for the Web Service:
1234567891011121314
$ cat /etc/systemd/system/concourse-web.service
[Unit]Description=Concourse CI web process (ATC and TSA)After=postgresql.service
[Service]User=concourse
Restart=on-failure
EnvironmentFile=/etc/concourse/web_environment
ExecStart=/usr/bin/concourse web
[Install]WantedBy=multi-user.target
Then the SystemD Unit File for the Worker Service:
1234567891011121314
$ cat /etc/systemd/system/concourse-worker.service
[Unit]Description=Concourse CI worker process
After=concourse-web.service
[Service]User=root
Restart=on-failure
EnvironmentFile=/etc/concourse/worker_environment
ExecStart=/usr/bin/concourse worker
[Install]WantedBy=multi-user.target
Create a postgres password for the concourse user:
1234
$ cd /home/concourse/
$ sudo -u concourse psql atc
atc=> ALTER USER concourse WITH PASSWORD 'concourse';atc=> \q
Start and Enable the Services:
1234567
$ systemctl start concourse-web concourse-worker
$ systemctl enable concourse-web concourse-worker postgresql
$ systemctl status concourse-web concourse-worker
$ systemctl is-active concourse-worker concourse-web
active
active
The listening ports should more or less look like the following:
Next, we need to setup our Concourse Target by Authenticating against our Concourse Endpoint, lets setup our target with the name ci, and make sure to replace the ip address with the ip of your concourse server:
123456789
$ fly -t ci login -c http://10.20.30.40:8080
logging in to team 'main'navigate to the following URL in your browser:
http://10.20.30.40:8080/login?fly_port=42181
or enter token manually (input hidden):
target saved
Lets list our targets:
123
$ fly targets
name url team expiry
ci http://10.20.30.40:8080 main Wed, 08 Nov 2021 15:32:59 UTC
Listing Registered Workers:
123
$ fly -t ci workers
name containers platform tags team state version
10.20.30.40 0 linux none none running 1.2
Listing Active Containers:
12
$ fly -t ci containers
handle worker pipeline job build # build id type name attempt
Hello World Pipeline:
Let’s create a basic pipeline, that will print out Hello, World!:
$ fly -t ci set-pipeline -p yeeehaa -c hello-world.yml
jobs:
job my-job has been added:
name: my-job
plan:
- task: say-hello
config:
platform: linux
image_resource:
type: docker-image
source:
repository: alpine
tag: edge
run:
path: /bin/sh
args:
- -c
- |echo"============="echo"Hello, World!"echo"============="apply configuration? [yN]: y
pipeline created!
you can view your pipeline here: http://10.20.30.40:8080/teams/main/pipelines/yeeehaa
the pipeline is currently paused. to unpause, either:
- run the unpause-pipeline command - click play next to the pipeline in the web ui
We can browse to the WebUI to unpause the pipeline, but since I like to do everything on cli as far as possible, I will unpause the pipeline via cli:
12
$ fly -t ci unpause-pipeline -p yeeehaa
unpaused 'yeeehaa'
Now our Pipeline is unpaused, but since we did not specify any triggers, we need to manually trigger the pipeline to run, you can either via the WebUI, select your pipeline which in this case will be named yeeehaa and then select the job, which will be my-job then hit the + sign, which will trigger the pipeline.
I will be using the cli:
12
$ fly -t ci trigger-job --job yeeehaa/my-job
started yeeehaa/my-job #1
Via the WebUI on http://10.20.30.40:8080/teams/main/pipelines/yeeehaa/jobs/my-job/builds/1 you should see the Hello, World! output, or via the cli, we also have the option to see the output, so let’s trigger it again, but this time passing the --watch flag:
123456789101112
$ fly -t ci trigger-job --job yeeehaa/my-job --watch
started yeeehaa/my-job #2initializing
running /bin/sh -c echo"============="echo"Hello, World!"echo"============="=============Hello, World!
=============succeeded
Listing our Workers and Containers again:
1234567
$ fly -t ci workers
name containers platform tags team state version
10.20.30.40 2 linux none none running 1.2
$ fly -t ci containers
handle worker pipeline job build # build id type name attempt36982955-54fd-4c1b-57b8-216486c58db8 10.20.30.40 yeeehaa my-job 2729 task say-hello n/a