Skip to content

Pipelines

The next service we will build is our pipelines service.

shellcheckit.gitlab-ci.yml

First, lets take a look at our shellcheckit.gitlab-ci.yml file.

shellcheckit.gitlab-ci.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
---

stages:
  - codrcodz-shellcheckit

.codrcodz-shellcheckit-job-template:
  image:
    name: registry.gitlab.com/codrcodz/pipelines-as-a-service/shellcheckit:mr-5
    entrypoint: ['']
  script:
    - /bin/entrypoint
  rules:
    # If last push is not to a branch that is part of an open merge request,
    # do not run this job.
    # TODO: When do we want this job to run?
    - if: $CI_PIPELINE_SOURCE != "?"
      when: never
    # If no other rules above match and tell GitlabCI not to run the job,
    # run this job.
    # (Note: this instruction is not strictly required since it is the default,
    #        but is here to be explicit about what will happen if nothing above matches)
    - when: always

codrcodz-shellcheckit-default-job:
  stage: codrcodz-shellcheckit
  extends:
    - .codrcodz-shellcheckit-job-template

...

Solution

shellcheckit.gitlab-ci.yml.solution
 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
---

stages:
  - codrcodz-shellcheckit

.codrcodz-shellcheckit-job-template:
  image:
    name: registry.gitlab.com/codrcodz/pipelines-as-a-service/shellcheckit:mr-5
    entrypoint: ['']
  script:
    - /bin/entrypoint
  rules:
    # If last push is not to a branch that is part of an open merge request,
    # do not run this job.
    - if: $CI_PIPELINE_SOURCE != "merge_request_event"
      when: never
    # If no other rules above match and tell GitlabCI not to run the job,
    # run this job.
    # (Note: this instruction is not strictly required since it is the default,
    #        but is here to be explicit about what will happen if nothing above matches)
    - when: always

codrcodz-shellcheckit-default-job:
  stage: codrcodz-shellcheckit
  extends:
    - .codrcodz-shellcheckit-job-template

...

Next, we will test the hook and pipeline using a separate "pipeline-tester" testing repository.

Head over to that repo and follow the instructions in the README.md.