All Projects â†’ Diabol â†’ jenkins-pipeline-shared-library-template

Diabol / jenkins-pipeline-shared-library-template

Licence: GPL-3.0 license
Project template for developing shared Jenkins pipeline libraries.

Programming Languages

groovy
2714 projects

Projects that are alternatives of or similar to jenkins-pipeline-shared-library-template

eryajf.github.io
📝 åĪ§åƒäļ–į•ŒïžŒä―•å…ķčŒŦčŒŦ。č°Ļæ­ĪįŽ”čŪ°ïžŒčŪ°å―•čŋ‡åū€ã€‚å‡­å›é˜…č§ˆïžŒå°įŦ™æī›č’。åĶ‚čƒ―æ”ķį›ŠïžŒčŽŦåĪ§åĨĒ望
Stars: ✭ 159 (+245.65%)
Mutual labels:  jenkins, jenkinsfile, jenkins-pipeline
Delivery Pipeline Plugin
Jenkins plugin for pipeline visualisation, perfect for Continuous Delivery
Stars: ✭ 122 (+165.22%)
Mutual labels:  jenkins, continuous-delivery, pipelines
pipeline-library
Shared libraries for Jenkinsfiles with unit tests
Stars: ✭ 22 (-52.17%)
Mutual labels:  jenkins, jenkins-pipeline, jenkins-pipeline-library
pipeline-as-yaml-plugin
Jenkins Pipeline As Yaml Plugin
Stars: ✭ 111 (+141.3%)
Mutual labels:  jenkins, jenkins-pipeline, pipeline-as-code
learn-ansible-and-jenkins-in-30-days
Ansible + Jenkins in 30 days tutorial.
Stars: ✭ 35 (-23.91%)
Mutual labels:  jenkins, jenkinsfile, jenkins-pipeline
one-click-microservice
A starting point for automating the creation of microservices and all its Ops costs with a single click.
Stars: ✭ 27 (-41.3%)
Mutual labels:  jenkins, continuous-delivery
Nevergreen
ðŸĪ A build monitor with attitude
Stars: ✭ 170 (+269.57%)
Mutual labels:  jenkins, continuous-delivery
community-edition
Zebrunner is a Test Automation Management Tool
Stars: ✭ 171 (+271.74%)
Mutual labels:  jenkins, continuous-delivery
jenny
Command line Jenkinsfile runner written in groovy. Does not need a Jenkins installation to run the Jenkinsfile.
Stars: ✭ 90 (+95.65%)
Mutual labels:  jenkins, jenkins-pipeline
Fabric8 Platform
Generates the distribution of the fabric8 microservices platform
Stars: ✭ 105 (+128.26%)
Mutual labels:  jenkins, continuous-delivery
Mkdkr
Make + Docker + Shell = CI Pipeline
Stars: ✭ 225 (+389.13%)
Mutual labels:  jenkins, pipelines
jenkins-k8sagent-lib
Jenkins Shared Library to get dynamic agent from Kubernetes cloud
Stars: ✭ 35 (-23.91%)
Mutual labels:  jenkins, jenkins-pipeline
Fabric8
fabric8 is an open source microservices platform based on Docker, Kubernetes and Jenkins
Stars: ✭ 1,783 (+3776.09%)
Mutual labels:  jenkins, continuous-delivery
Cdeasy
Continuous Delivery made Easy ;)
Stars: ✭ 143 (+210.87%)
Mutual labels:  jenkins, continuous-delivery
Jenkinsfiles
Examples for jenkins pipelines, comparing scripted and declarative syntax
Stars: ✭ 187 (+306.52%)
Mutual labels:  jenkins, continuous-delivery
ebook-continuous-delivery-with-kubernetes-and-jenkins
Continuous Delivery for Java Apps: Build a CD Pipeline Step by Step Using Kubernetes, Docker, Vagrant, Jenkins, Spring, Maven and Artifactory
Stars: ✭ 39 (-15.22%)
Mutual labels:  jenkins, continuous-delivery
artifact-promotion-plugin
A simple Jenkins plugin to promote artifacts.
Stars: ✭ 29 (-36.96%)
Mutual labels:  jenkins, continuous-delivery
Jenkins Pipeline
📈 Learn how to implement container technologies with your Jenkins CI/CD workflows to make them easier to manage in this tutorial.
Stars: ✭ 83 (+80.43%)
Mutual labels:  jenkins, continuous-delivery
Docker For All
Docker applied in development, devops, testing, product management etc.
Stars: ✭ 88 (+91.3%)
Mutual labels:  jenkins, continuous-delivery
openshift-wiki
Gitbook URL of WIKI
Stars: ✭ 16 (-65.22%)
Mutual labels:  jenkinsfile, jenkins-pipeline

Jenkins Pipeline Shared Library Template

This project is intended for use with Jenkins and Global Pipeline Libraries through the Pipeline Shared Groovy Libraries Plugin.

A common scenario when developing Jenkins declarative pipelines, is to bundle common custom pipeline tasks in a shared library so that all Jenkins pipeline configurations in an organisation can leverage from them without the need to reimplement the same logic.

This project provides a project template for developing shared Jenkins pipeline libraries as specified in the Jenkins documentation. The project is setup using Gradle which enables you to develop and unit test your custom Jenkins pipeline library code.

Requirements

Apache Groovy

Install

git clone https://github.com/Diabol/jenkins-pipeline-shared-library-template.git
cd jenkins-pipeline-shared-library-template
./gradlew build test

Install the shared library as described in the Jenkins shared library documentation.

Structure

The project contains an example pipeline method maintainer, which allows you to output the project maintainer in the console log. This is only used as an example. Adapt and add new classes according to your needs.

├── src                       (your source code classes goes here)
│   └── se.diabol.jenkins.pipeline.lib
│       └── Constants.groovy  (example Groovy class)
├── test                      (your unit test classes goes here)
│   └── MaintainerTest.groovy (example unit test class)
└── vars                      (your shared library classes goes here)
    └── maintainer.groovy     (logic for your custom method - filename to match Jenkins pipeline step name)

Example usage in a Jenkins declarative pipeline:

/**
 * Library name should match the name configured in Jenkins > Configure system > Global Pipeline Libraries.
 * Annotation can be omitted if configured to be loaded implicitly.
 */
@Library('jenkins-pipeline-shared-library-template') _
pipeline {
    agent any
    stages {
        stage('Commit stage') {
            steps {
                maintainer 'Diabol AB'
            }
        }
    }
}

Pipeline console output:

Started by user anonymous
Loading library jenkins-pipeline-shared-library-template@master
...
[Pipeline] node
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Commit stage)
[Pipeline] echo
Project maintained by Diabol AB
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

Considerations

For many use cases there is a benefit in providing a custom and simplified DSL to create Jenkins pipelines, instead of requiring repetitive pipeline configurations for each project. So instead of each project specifying a full configuration such as in the example above, the pipeline itself can be extracted to a pipeline method (residing in the vars directory).

Example: vars/continuousDeliveryPipeline.groovy

#!groovy

def call(body) {
    def config = [:]
    body.resolveStrategy = Closure.DELEGATE_FIRST
    body.delegate = config
    body()
    
    pipeline {
        agent any
        stages {
            stage('Commit stage') {
                steps {
                    maintainer config.maintainer
                }
            }
        }
    }
}

... which allows your pipeline configuration (e.g. in a Jenkinsfile) to look like:

continuousDeliveryPipeline {
    maintainer = 'Diabol AB'
}

with a convenient DSL with less need for repetition in your pipeline configurations.

Configuration

The library name used in the pipeline script must match what is configured as the library name in Jenkins > Configure system > Global Pipeline Libraries. See this blog post on how to configure shared groovy libraries programmatically: http://blog.diabol.se/?p=1052

Contact and feedback

Feel free to open an issue or pull request if you find areas of improvement.

Maintained by Diabol AB

Happy pipelining!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].