• This repository has been archived on 04/Jul/2018
  • Stars
    star
    274
  • Rank 144,734 (Top 3 %)
  • Language
    Groovy
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a collection of reusable jenkins pipelines and pipeline functions

WARNING THIS REPOSITORY IS NOW DEPRECATED!

NOTE please use one of these repositories instead:

Table of Contents

Fabric8 Jenkins Pipeline Library

This git repository contains a library of reusable Jenkins Pipeline scripts that can be used on a project.

fabric8 logo

The idea is to try promote sharing of scripts across projects where it makes sense.

You can then either

  • reuse any of the flows as is
  • fork this repository and make your own changes (hopefully submitting a Pull Request back)
  • copy flows from this project into your own projects source code where you can modify it further

Requirements

These flows make use of the Fabric8 DevOps Pipeline Steps and kubernetes-pipeline-plugin which help when working with Fabric8 DevOps in particular for clean integration with the Hubot chat bot and human approval of staging, promotion and releasing.

How it works

With the Jenkins global library we can take advantage from a shared library of reusable scripts. When the fabric8 Jenkins app is run, we use a kubernetes post start script to populate the Jenkins internal global library with scripts from this repo. We are then able to easily call the groovy functions from within our Jenkinsfiles.

NOTE Hopefully we will switch to using Kubernetes initContainers when they're available to help with this.

These scripts are baked into the fabric8 jenkins docker image during the fabric8 release however you can override this repo by updating the parameters when running the Jenkins app from the fabric8 console.

Functions from the Jenkins global library

Approve

  • requests approval in a pipeline
  • hubot integration prompting chat room for approvals including links to environments
  • sends events to elasticsearch if running in a configured namespace, this helps OOTB charting of approval wait times

example..

    approve{
      version = '0.0.1'
      console = 'http://fabric8.kubernetes.fabric8.io'
      environment = 'staging'
    }

Deploy Project

  • applies a kubernetes json resource to the host OpenShift / Kubernetes cluster
  • lazily creates the environment if it doesn't already exist
    deployProject{
      stagedProject = 'my-project'
      resourceLocation = 'target/classes/kubernetes.json'
      environment = 'staging'
    }

Drop Project

in the case of an aborted approval

  • will drop the an OSS sonartype staged repository
  • close any pull requests that have been created based on the release
  • delete the branch relating to the PR mentioned above
    dropProject{
      stagedProject = project
      pullRequestId = '1234'
    }

Get Kubernetes JSON

  • returns a default OpenShift templates that gets translated into Kubernetes List when applied by kubernetes-workflow apply step and running on Kubernetes
  • returns a service and replication controller JSON using sensible defaults
  • can be used in conjunction with kubernetesApply
    node {
        def rc = getKubernetesJson {
          port = 8080
          label = 'node'
          icon = 'https://cdn.rawgit.com/fabric8io/fabric8/dc05040/website/src/images/logos/nodejs.svg'
          version = '0.0.1'
        }

        kubernetesApply(file: rc, environment: 'my-cool-app-staging', registry: 'myexternalregistry.io:5000')
    }

Get New Version

  • returns the short git sha for the current project to be used as a version
    def newVersion = getNewVersion{}

Maven Canary Release

  • creates a release branch
  • sets the maven pom versions using versions-maven-plugin
  • runs mvn deploy docker:build
  • generates maven site and deploys it to the content repository
    mavenCanaryRelease{
      version = canaryVersion
    }

Maven Integration Test

  • lazily creates a test environment in kubernetes
  • runs maven integration tests in test environment
    mavenIntegrationTest{
      environment = 'Testing'
      failIfNoTests = 'false'
      itestPattern = '*KT'
    }

Merge and Wait for Pull Request

  • adds a [merge] comment to a github pull request
  • waits for GitHub pull request to be merged by an external CI system
    mergeAndWaitForPullRequest{
      project = 'fabric8/fabric8'
      pullRequestId = prId
    }

Perform Canary Release

  • generic function used by non Java based project
  • gets a new version based on the short git sha
  • builds docker image using a Dockerfile in the root of the project
  • tags the image with the release version and prefixes the private fabric8 docker registry for the current namespace
  • if running in a multi node cluster will perform a docker push. Not needed in a single node setup as image built and cached locally
    stage 'Canary release'
    echo 'NOTE: running pipelines for the first time will take longer as build and base docker images are pulled onto the node'
    if (!fileExists ('Dockerfile')) {
      writeFile file: 'Dockerfile', text: 'FROM django:onbuild'
    }

    def newVersion = performCanaryRelease {}

REST Get URL

  • utility function returning the JSON contents of a REST Get request
    def apiUrl = new URL("https://api.github.com/repos/${config.name}/pulls/${id}")
    JsonSlurper rs = restGetURL{
      authString = githubToken
      url = apiUrl
    }

Update Maven Property Version

During a release involving multiple java projects we often need to update downstream maven poms with new versions of a dependency. In a release pipeline we want to automate this, set up a pull request and let CI run to make sure there's no conflicts.

  • performs a search and replace in the maven pom
  • finds the latest version available in maven central (repo is configurable)
  • if newer version exists pom is updated
  • pull request submitted
  • pipeline will wait until this is merged before continuing

If CI fails and updates are required as a result of the dependency upgrade then

  • pipeline will notify a chat room (we use Slack)
  • informs the team of the git commands needed to clone, switch to the version update branch and command to push back once fixed
  • pipeline will wait until the CI passes before continuing

Automating this has saved us a lot of time during the release pipeline

    def properties = []
    properties << ['<fabric8.version>','io/fabric8/kubernetes-api']
    properties << ['<docker.maven.plugin.version>','io/fabric8/docker-maven-plugin']

    updatePropertyVersion{
      updates = properties
      repository = source // if null defaults to http://central.maven.org/maven2/
      project = 'fabric8io/ipaas-quickstarts'
    }

Wait Until Artifact Synced With Maven Central

When working with open source java projects we need to stage artifacts with OSS Sonartype in order to promote them into maven central. This can take 10-30 mins depending on the size of the artifacts being synced.

A useful thing is to be notified in chat when artifacts are available in maven central as blocking the pipeine until we're sure the promote has worked.

  • polls waiting for artifacts to be available in maven central
    waitUntilArtifactSyncedWithCentral {
      repo = 'http://central.maven.org/maven2/'
      groupId = 'io.fabric8.archetypes'
      artifactId = 'archetypes-catalog'
      version = '0.0.1'
      ext = 'jar'
    }

Wait Until Pull Request Merged

During a CD pipeline we often need to wait for external events to complete before continuing. One of the most common events we have on the fabric8 project is waiting for CI jobs or manually review and approval of github pull requests. We don't want to fail a pipeline, rather just wait patiently for the pull requests to merge so we can continue.

  • pull request submitted
  • pipeline will wait until this is merged before continuing

If CI fails and updates are required as a result of the dependency upgrade then

  • pipeline will notify a chat room (we use Slack)
  • informs the team of the git commands needed to clone, switch to the version update branch and command to push back once fixed
  • pipeline will wait until the CI passes before continuing
    waitUntilPullRequestMerged{
      name = 'fabric8io/fabric8'
      prId = '1234'
    }

fabric8 release

These functions are focused specifically on the fabric8 release itself however could be used as examples or extended in users own setup.

The core fabric8 release consists of multiple Java projects that generate Java artifacts, docker images and kubernetes resources. These projects are built and staged together, automatically deployed into a test environment and after approval promoted together ready for the community to use.

When a project is staged an array is returned and passed around functions further down the pipeline. The structure of this stagedProject array is in the form [config.project, releaseVersion, repoId]

  • config.project the name of the github project being released e.g. 'fabric8io/fabric8'
  • releaseVersion the new version e.g. '0.0.1'
  • repoId the OSS Sonartype staging repository Id used to interact with Sonartype later on
    def stagedProject = stageProject{
      project = 'fabric8io/ipaas-quickstarts'
      useGitTagForNextVersion = true
    }

One other important note is on the fabric8 project we don't use the maven release plugin or update to next SNAPSHOT versions as it causes unwanted noise and commits to our many github repos. Instead we use a fixed development x.x-SNAPSHOT version so we can easily work in development on multiple projects that have maven dependencies with each other.

Now that we don't store the next release version in the poms we need to figure it out during the release. Rather than store the version number in the repo which involves a commit and not too CD friendly (i.e. would trigger another release just for the version update) we use the git tag. From this we can get the previous release version, increment it and push it back without triggering another release. This seems a bit strange but it has been holding up and has significantly reduced unwanted SCM commits related to maven releases.

Promote Artifacts

  • releases OSS sonartype staging repository so that artifacts are synced with maven central
  • commits generated Helm charts to the fabric8 Helm repo
  • if useGitTagForNextVersion is set (true by default) then the next snapshot development version PR is committed
    String pullRequestId = promoteArtifacts {
      projectStagingDetails = config.stagedProject
      project = 'fabric8io/fabric8'
      useGitTagForNextVersion = true
      helmPush = false
    }

Release Project

  • promotes artifacts from OSS sonartype staging repo to maven central
  • promotes images from internal docker registry to dockerhub
  • waits for github pull request to merge if updating next snapshot version (not used by default)
  • waits for artifacts to be synced and available in maven central
  • sends chat notification when artifacts appear in maven central
    releaseProject{
      stagedProject = project
      useGitTagForNextVersion = true
      helmPush = false
      groupId = 'io.fabric8.archetypes'
      githubOrganisation = 'fabric8io'
      artifactIdToWatchInCentral = 'archetypes-catalog'
      artifactExtensionToWatchInCentral = 'jar'
    }

Stage Extra Images

  • takes a list of external images not built by the CD pipeline which need tagging in dockerhub with the new release version
  • pulls the latest images from dockerhub
  • tags them with the new fabric8 release
  • stages them in the internal docker registry
    stageExtraImages {
      images = ['gogs','jenkins','taiga']
      tag = releaseVersion
    }

Stage Project

  • builds and stages a fabric8 java project with OSS sonartype
  • build docker images and stages them in the internal docker registry
  • stages extra images not built by docker-maven-plugin in the internal docker registry
    def stagedProject = stageProject{
      project = 'fabric8io/ipaas-quickstarts'
      useGitTagForNextVersion = true
    }

Tag Images

  • will pull external images which have been staged in the fabric8 docker registry and push the new tag to dockerhub
    tagImages{
      images = ['gogs','jenkins','taiga']
      tag = releaseVersion
    }

Git Tag

  • tags the current git repo with the provided version
  • pushes the tag to the remote repository
    gitTag{
      releaseVersion = '0.0.1'
    }

Deploy Remote OpenShift

Deploys the staged fabric8 release to a remote OpenShift cluster

NOTE in order for images to be found by the the remote OpenShift instance it must be able to pull images from the staging docker registry. Noting private networks and insecure-registry flags.

    node{
      deployRemoteOpenShift{
        url = openshiftUrl
        domain = 'staging'
        stagingDockerRegistry = openshiftStagingDockerRegistryUrl
      }
    }

Deploy Remote Kubernetes

Deploys the staged fabric8 release to a remote Kubernetes cluster

NOTE in order for images to be found by the the remote OpenShift instance it must be able to pull images from the staging docker registry. Noting private networks and insecure-registry flags.

    node{
      deployRemoteKubernetes{
        url = kubernetesUrl
        defaultNamespace = 'default'
        stagingDockerRegistry = kubernetesStagingDockerRegistryUrl
      }
    }

More Repositories

1

kubernetes-client

Java client for Kubernetes & OpenShift
Java
3,266
star
2

docker-maven-plugin

Maven plugin for running and creating Docker images
Java
1,822
star
3

fabric8

fabric8 is an open source microservices platform based on Docker, Kubernetes and Jenkins
1,773
star
4

spring-cloud-kubernetes

Kubernetes integration with Spring Cloud
Java
703
star
5

fabric8-pipeline-library

Fabric8 Pipeline for Jenkins
Groovy
431
star
6

fluent-plugin-kubernetes_metadata_filter

Enrich your fluentd events with Kubernetes metadata
Ruby
349
star
7

fabric8-maven-plugin

๐Ÿ“ข This project is migrated to ๐Ÿ‘‰ https://github.com/eclipse/jkube
Java
335
star
8

kubeflix

Kubernetes integration with Netflix OSS
267
star
9

kansible

Kansible lets you orchestrate operating system processes on Windows or any Unix in the same way as you orchestrate your Docker containers with Kubernetes by using Ansible to provision the software onto hosts and Kubernetes to orchestate the processes
Go
263
star
10

configmapcontroller

Go
206
star
11

fabric8-jenkinsfile-library

This repository contains a library of reusable Jenkinsfiles that you can use on your projects. Its reused by the fabric8 console to associate Jenkinsfiles to projects
Groovy
187
star
12

elasticsearch-cloud-kubernetes

Java
169
star
13

gofabric8

CLI used when working with fabric8 running on Kubernetes or OpenShift
Go
147
star
14

mockwebserver

An extension of okhttp's mockwebserver, that provides a DSL and is easier to use
Java
112
star
15

fabric8-platform

Generates the distribution of the fabric8 microservices platform
Shell
104
star
16

shootout-docker-maven

A comparison between the four major docker-maven-plugins
Java
84
star
17

jenkins-docker

docker file for a jenkins docker image
Groovy
82
star
18

kubernetes-zipkin

Kubernetes integration with OpenZipkin
Java
69
star
19

ipaas-quickstarts

quickstarts for the fabric8 project
Java
66
star
20

fabric8-devops

Contains the pluggable apps that can be run as part of the fabric8 DevOps platform on any OpenShift v3 or Kubernetes environment
63
star
21

agent-bond

A Super Java Agent
Java
46
star
22

gitcontroller

A simple microservice which watches Kubernetes Deployments which are using gitRepo volumes and if git has changed, updates the Deployment
Go
44
star
23

docker-fluentd-kubernetes

Shell
43
star
24

kubernetes-model

JSON schema generator for OpenShift Origin API objects
36
star
25

fabric8-docker

Dockerfiles to create Fuse containers in docker.io
Shell
33
star
26

fabric8-console

Angular 1.x console for fabric8
28
star
27

openshift-elasticsearch-plugin

Java
27
star
28

jube

jube is a deprecated pure java implementation of kubernetes. Please look at kansible now instead!
Java
27
star
29

vertx-maven-plugin

Vert.x Maven Plugin - moved to https://github.com/reactiverse/vertx-maven-plugin
Java
25
star
30

openshift-auth-proxy

A reverse proxy that authenticates the request against OpenShift, retrieving user information & setting the configured header with the appropriate details.
JavaScript
18
star
31

fabric8-zookeeper-docker

Shell
18
star
32

fluent-plugin-kubernetes

Ruby
16
star
33

fabric8-ipaas

This repository contains the iPaaS related apps that can be run as part of the fabric8 platform on any OpenShift v3 and Kubernetes environment
14
star
34

osio-pipeline

DSL and utility functions in groovy for running Jenkins OSIO Pipeline
Groovy
13
star
35

fabric8-installer

To install fabric8 into a Kubernetes, OpenShift or Atomic environment
Ruby
12
star
36

kubernetes-alexa

A skill that allows Alexa to interact with a Kubernetes / Openshift cluster
Java
12
star
37

docker-gerrit

a docker image for gerrit
Shell
12
star
38

sandbox-fabric8-devops

A repository of devops examples for automatically provisioning and testing fabrics on different infrastructure
Ruby
12
star
39

fabric8-jenkins-workflow-steps

fabric8 based jenkins workflow steps
11
star
40

docker-client

11
star
41

kubernetes-assertions

This library provides a bunch of helpful assertj assertions for working with the kubernetes-api
Java
10
star
42

fabric8-forge

Supports JBoss Forge plugins for the Fabric8 iPaaS along with using Forge as a REST service inside Fabric8 DevOps
Java
10
star
43

docker-gogs

Go
9
star
44

fabric8-ansible-spring-boot

an Ansible playbook for provisioning Spring Boot apps
9
star
45

docker-dirsrv-389ds

Docker Image repo for 389ds Fedora Directory Server
Shell
9
star
46

fabric8-kit

Building blocks for the fabric8 Developer Toolbox (i.e. the Maven plugins)
Java
9
star
47

templates

the default templates to use inside the fabric8 console
Shell
9
star
48

data-mapper

data mapper tooling
7
star
49

jenkins-pipeline-dsl

Groovy
7
star
50

fabric8-online-docs

Shell
7
star
51

docker-cfssl

Shell
7
star
52

docker-grafana

Shell
7
star
53

hawtio-docker

NOTE: now replaced by fabric8/fabric8-console image. This project creates the fabric8/hawtio docker image
Shell
6
star
54

fluent-plugin-docker_metadata_filter

Ruby
6
star
55

default-jenkins-dsl

The default jenkins job DSL build for automatically performing CI and CD on local gogs repositories inside fabric8
Groovy
6
star
56

jenkins_exporter

Prometheus exporter for Jenkins
Go
4
star
57

fabric8-test

Python
4
star
58

fabric8-ansible-hawtapp

a sample Ansible playbook that provisions a fabric8 hawtapp onto boxes
Shell
4
star
59

docker-kibana4

Shell
4
star
60

jadvisor

Go
4
star
61

fabric8-keycloak-theme

CSS
4
star
62

fabric8-envoy

a distribution of Envoy for running on kubernetes or openshift
Shell
4
star
63

grafana-kubernetes-app

JavaScript
4
star
64

fabric8-eclipse-orion

docker packaging of eclipse orion web based IDE
3
star
65

jenkinshift

A simple REST Facade that makes Jenkins Jobs and Build Runs appear as if they are OpenShift BuildConfig / Build objects so that the fabric8-console can still view apps/builds when using Jenkins on vanilla kubernetes
Go
3
star
66

traefik

a kubernetes app for running traefik.io
3
star
67

envsubst

docker image to replace placeholders in a file with env var values
Shell
3
star
68

docker-iptables-redirector

A simple Docker image that redirects traffic via DNAT to a different address/port
Shell
3
star
69

hubot-mattermost

2
star
70

docker-prometheus

2
star
71

hubot-slack

2
star
72

fabric8-release-pipelines

fabric8 release pipeline project that contains the Jenkinsfiles for multi project release
Groovy
2
star
73

hubot-base

2
star
74

jenkins-jnlp-client

Jenkins JNLP Client Docker Image
Shell
2
star
75

fabric8-ci-seed

a Jenkins Job DSL script to auto generate pull request CI jobs for projects such as the quickstarts
Groovy
2
star
76

fabric8-online

Groovy
2
star
77

fabric8-hubot-scripts

scripts for running hubot on fabric8
CoffeeScript
2
star
78

jenkins-slave-docker

Jenkins Slave Docker Image
Shell
2
star
79

dirsrv-389ds

389ds application for OpenShift/Kubernetes
Groovy
2
star
80

jenkernetes-docker

Shell
2
star
81

fabric8-gogs-find-projects

creates a docker container to find repos in gogs for use in jenkins workflow scripts
Java
2
star
82

fabric8-spring

A project to help folks use Spring Boot with Kubernetes or OpenShift
2
star
83

go-builder

Builder image used by Kubernetes Workflow and Jenkinsfile to build golang images
1
star
84

hubot-irc

1
star
85

insight

1
star
86

fabric8-brackets

a docker package for the http://brackets.io/ editor
1
star
87

django-examples

Camel iPaaS functionality examples
1
star
88

docker-logstash

Shell
1
star
89

maven-nexus-docker

a nexus aware docker image for maven
1
star
90

jenkins-slave-dind-maven

a jenkins slave with dind and a pre-installed maven docker image
Shell
1
star
91

ianaservicehelper

Java
1
star
92

gitcollector

collects git and github related events from projects inside OpenShift
Go
1
star
93

jenkins-slave-dind

A Docker in Docker Jenkins Slave
Shell
1
star
94

docker-fluentd

1
star
95

caddy-server

1
star
96

ipaas-platform

Generates the distribution of the ipaas platform
Groovy
1
star
97

docker-influxdb

Go
1
star
98

fabric8-generator

a jboss forge add on for the fabric8 upstream and SaaS generator wizards
Java
1
star
99

fabric8-jbpm-designer

Shell
1
star
100

fabric8-profiles

fabric8-profiles provides an abstraction for sharing configuration across apps in a convention over configuration way
1
star