Using the ConcourseCI pull request resource to verify Docker builds
Concourse.ci offers a free, open source continuous integration and delivery tool through which software development teams can establish and manage delivery pipelines.
Problem: TravisCI can be configured to run CI against a docker image's source code repository. But how can Concourse's pull-request resource be configured to test that docker build of a Dockerfile works as expected in a repo that houses such a Dockerfile?
Solution: Configure the Concourse's pull request verification job to use the docker-image resource type, thus performing a docker build using the Dockerfile during a pull request's continuous integration. Note line 41 in the pipeline.yml.
The pipeline.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | resources:
# source code
- name: docker-foo
type: git
source:
branch: master
uri: git@github.com:username/docker-foo.git
# foo docker image
- name: foo-docker-image
type: docker-image
source:
repository: docker.your-company.com/username/foo
# docker-foo pull request resource
- name: docker-foo-pull-request
type: pull-request
source:
uri: git@github.comcast.com:aae/cloud-tools.git
repo: username/docker-foo
resource_types:
- name: pull-request
type: docker-image
source:
repository: jtarchie/pr
jobs:
# verify a pull request
- name: verify-pull-request
plan:
- get: docker-foo-pull-request
trigger: true
- put: docker-foo-pull-request
params:
path: docker-foo-pull-request
status: pending
# test in ConcourseCI that the PR's `Dockerfile` edits work as expected:
- put: foo-docker-image
params:
build: docker-foo-pull-request
on_success:
put: docker-foo-pull-request
params:
path: docker-foo-pull-request
status: success
on_failure:
put: docker-foo-pull-request
params:
path: docker-foo-pull-request
status: failure
# build foo docker image from `master`
- name: publish-docker-image
serial: true
plan:
- get: docker-foo
trigger: false
- put: foo-docker-image
params:
build: foo
tag: foo/version
|