Giter Site home page Giter Site logo

moodring's Introduction

tekton-commit-status-tracker

Build Status

Forked from https://github.com/tektoncd/experimental/tree/master/commit-status-tracker

Overview

This operator tracks completed Tekton PipelineRuns and attempts to create a GitHub Commit Status with the success or failure of the PipelineRun.

Why?

If you're running tasks that are important parts of your deployment flow, you can define policies that require specific checks are carried out before code can be merged.

These can be enforced by GitHub, using their branch protection mechanism.

If you want your Tekton Pipelines to be a part of this, then you'll want to report the success or failure of your PipelineRuns to Github (you might also want Tasks, but that's not implemented yet).

This is an operator-sdk originated operator.

Annotating a PipelineRun

The operator watches for PipelineRuns with specific annotations.

This is an alpha operator, and the annotation names will likely change, but for now you'll need...

apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
  name: demo-pipeline-run
  annotations:
    "tekton.dev/git-status": "true"
    "tekton.dev/status-context": "demo-pipeline"
    "tekton.dev/status-description": "this is a test"
spec:
  pipelineRef:
    name: demo-pipeline
  serviceAccountName: 'default'
  resources:
  - name: source
    resourceSpec:
      type: git
      params:
        - name: revision
          value: insert revision
        - name: url
          value: https://github.com/this/repo

The revision here should be the full commit SHA from the HEAD of a branch associated with a Pull Request.

The annotations are:

Name Description Required Default
tekton.dev/git-status This indicates that this PipelineRun should trigger commit-status notifications. Yes
tekton.dev/status-context This is the context that will be reported, you can require named contexts in your branch protection rules. No "default"
tekton.dev/status-description This is used as the description of the context, not the commit. No ""
tekton.dev/status-target-url If provided, then this will be linked in the GitHub web UI, this could be used to link to logs or output. No ""

Detecting the Git Repository

Currently, this uses a simple mechanism to find the Git repository and SHA to update the status of.

It looks for a single PipelineResource of type git and pulls the url and revision from there.

If no suitable PipelineResource is found, then this will be logged as an error, and not retried.

Prerequisites

  • go version v1.13+.
  • docker version 17.03+
  • kubectl v1.11.3+
  • [operator-sdk][operator_install]
  • Access to a Kubernetes v1.11.3+ cluster

Getting Started

Cloning the repository

Checkout the Operator repository

$ git clone https://github.com/tektoncd/experimental.git
$ cd experimental/commit-status-tracker

Pulling the dependencies

Run the following command

$ go mod tidy

Building the operator

Build the operator image and push it to a public registry, such as quay.io:

$ export IMAGE=quay.io/example-inc/commit-status-tracker:v0.0.1
$ operator-sdk build $IMAGE
$ docker push $IMAGE

Using the image

# Update the operator manifest to use the built image name (if you are performing these steps on OSX, see note below)
$ sed -i 's|REPLACE_IMAGE|quay.io/example-inc/commit-status-tracker:v0.0.1|g' deploy/operator.yaml
# On OSX use:
$ sed -i "" 's|REPLACE_IMAGE|quay.io/example-inc/commit-status-tracker:v0.0.1|g' deploy/operator.yaml

NOTE The quay.io/example-inc/commit-status-tracker:v0.0.1 is an example. You should build and push the image for your repository.

Installing

You must have Tekton Pipeline installed before installing this operator:

$ kubectl apply -f https://github.com/tektoncd/pipeline/releases/download/v0.10.1/release.yaml

And then you can install the statuses operator with:

$ kubectl create -f deploy/service_account.yaml
$ kubectl create -f deploy/role.yaml
$ kubectl create -f deploy/role_binding.yaml
$ kubectl create -f deploy/operator.yaml

Uninstalling

$ kubectl delete -f deploy/service_account.yaml
$ kubectl delete -f deploy/role.yaml
$ kubectl delete -f deploy/role_binding.yaml
$ kubectl delete -f deploy/operator.yaml

Troubleshooting

Use the following command to check the operator logs.

$ kubectl logs commit-status-tracker

Running Tests

$ go test -v ./...

moodring's People

Contributors

aeweidne avatar booninite avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

bviswana101

moodring's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.