PipelineLib/Guides/How to configure CI for your project

From Wikitech
Jump to navigation Jump to search

Welcome to Configure our CI system to execute your pipeline, a simple PipelineLib guide to get your project's newly defined test pipeline running for each patchset submitted to Gerrit.

Prerequisites

  • This guide is meant as a supplement to one of the language specific guides. Follow one that fits with your project before continuing here.
  • Some knowledge of JJB/Zuul and how to edit integration/config would definitely help during this guide, but you can probably get by with just following the simple steps herein.

Guide

Configure our CI system to execute your pipeline

We're not quite to full self-service CI yet, so you still have to add a little of your own glue to tell our CI system how to invoke your newly defined test pipeline.

Clone integration/config

dev@laptop:~$ git clone ssh://gerrit.wikimedia.org:29418/integration/config src/integration/config
dev@laptop:~$ cd src/integration/config

Tell Jenkins about your project's test pipeline

Define a project entry in the jjb/project-pipelines.yaml file in integration/config.

dev@laptop:config$ vim jjb/project-pipelines.yaml
 1 # [...]
 2 - project:
 3     name: my-project
 4     pipeline:
 5       - test
 6     jobs:
 7       # defines jobs:
 8       #   trigger-my-project-pipeline-test
 9       #   my-project-pipeline-test
10       - 'trigger-{name}-pipeline-{pipeline}'
11       - '{name}-pipeline-{pipeline}'
12 # [...]

There are two important lines here specific to your project—the rest is boilerplate. They are:

  1. The name of your project.
  2. The name(s) of the pipeline(s) you have defined in your .pipeline/config.yaml.

Tell Zuul to invoke your pipeline jobs to test project patchsets

Add new Zuul project test entries in the zuul/layout.yaml file in integration/config.

dev@laptop:config$ vim zuul/layout.yaml

Look under the projects: section in zuul/layout.yaml for your project, and add the trigger job under the test and gate-and-submit subsections.

# [...]
projects:
# [...]
  - name: my-project/repo/path/in/gerrit
    test:
      - trigger-my-project-pipeline-test
    gate-and-submit:
      - trigger-my-project-pipeline-test
# [...]

Commit your changes, and submit your patch for review!

dev@laptop:config$ git checkout -b add-my-project-test-pipeline
dev@laptop:config$ git add jjb/project-pipelines.yaml zuul/layout.yaml
dev@laptop:config$ git commit -em 'jjb: Define test pipeline for my-project' # and say a little more in the commit msg
dev@laptop:config$ git push origin HEAD:refs/for/master