OpenStack logo

Trunk Gating with Jenkins, Gerrit, and Zuul

James E. Blair <jeblair@openstack.org>

About this Presentation

OpenStack

Is open source software for building private and public clouds.

Projects

Contributors

Vision

Consistent Tooling

Gated Trunk

Everything Is Automated

Process Flow

Gerrit

States of a Patch

Types of Gerrit Triggers

Jenkins Feedback

Jenkins

Types of jobs:

Zuul

Speculative Execution

Zuul Simulation

Zuul Check Pipeline

pipelines:
  - name: check
    manager: IndependentPipelineManager
    trigger:
      - event: patchset-created
    success:
      verified: 1
    failure:
      verified: -1

Zuul Gate Pipeline

pipelines:
  - name: gate
    manager: DependentPipelineManager
    trigger:
      - event: comment-added
        approval:
          - approved: 1
    start:
      verified: 0
    success:
      verified: 2
      submit: true
    failure:
      verified: -2

Zuul Post-Merge Pipeline

pipelines:
  - name: post
    manager: IndependentPipelineManager
    trigger:
      - event: ref-updated
        ref: ^(?!refs/).*$

Other Pipelines We've Created

pipelines:
  - name: silent
    manager: IndependentPipelineManager
    trigger:
      - event: patchset-created

  - name: publish
    manager: IndependentPipelineManager
    trigger:
      - event: ref-updated
        ref: ^refs/tags/.*$

Zuul Project Configuration

projects:
  - name: openstack/nova
    check:
      - gate-nova-merge:
        - gate-nova-pep8
        - gate-nova-python26
        - gate-nova-python27
        - gate-tempest-devstack-vm
    gate:
      - gate-nova-merge:
        - gate-nova-pep8
        - gate-nova-python26
        - gate-nova-python27
        - gate-tempest-devstack-vm
    post:
      - nova-tarball
      - nova-docs

Zuul Change Queues

Projects with shared jobs automatically get a shared queue:

projects:
  - name: openstack/nova
    gate:
      - gate-nova-merge:
        - gate-nova-python27
        - gate-tempest-devstack-vm

  - name: openstack/glance
    gate:
      - gate-glance-merge:
        - gate-glance-python27
        - gate-tempest-devstack-vm

Status View

Jenkins API

Jenkins API: Launching

The python library jenkins allows for easy interaction:

from jenkins import Jenkins
jenkins = Jenkins('servername', 'username', 'apikey')
jenkins.build_job(job.name, parameters=params)

Abstracts simple GET/POST transactions.

Jenkins API: Notifications

Notification plugin provides for HTTP endpoints.

class JenkinsCallback(threading.Thread):
    def run(self):
        httpserver.serve(self.app, host='0.0.0.0', port='8001')

    def app(self, environ, start_response):
        request = Request(environ)
        start_response('200 OK', [('content-type', 'text/html')])
        if request.path == '/jenkins_endpoint':
            data = json.loads(request.body)
            build = data.get('build')
            phase = build.get('phase')
            status = build.get('status')
            url = build.get('full_url')
            number = build.get('number')
            params = build.get('parameters')
        return ['OK']

Development / Contributing

Thanks!

These slides available at: https://github.com/openstack-ci/publications