All Projects → Invoca → jenkins-pipeline

Invoca / jenkins-pipeline

Licence: MIT license
Jenkins Pipeline Shared Library

Programming Languages

groovy
2714 projects

Projects that are alternatives of or similar to jenkins-pipeline

soccer-stats
Soccer Stats is an example application to be used as a proof of concept for a presentation at Ansible Meetup in São Paulo
Stars: ✭ 83 (+418.75%)
Mutual labels:  jenkins, jenkins-pipeline
jenkinsfile cookbook pipeline
Example Jenkinsfile and Explaination for Chef Cookbook Development
Stars: ✭ 36 (+125%)
Mutual labels:  jenkins, jenkins-pipeline
pipeline-library
Shared libraries for Jenkinsfiles with unit tests
Stars: ✭ 22 (+37.5%)
Mutual labels:  jenkins, jenkins-pipeline
jenkins-pipeline-global-library-chefci
Jenkins Pipeline's "Workflow Global Libs" for Chef CI
Stars: ✭ 60 (+275%)
Mutual labels:  jenkins, jenkins-pipeline
plot-plugin
Jenkins plot plugin
Stars: ✭ 54 (+237.5%)
Mutual labels:  jenkins, jenkins-pipeline
ods-jenkins-shared-library
Shared Jenkins library which all ODS projects & components use - provisioning, SonarQube code scanning, Nexus publishing, OpenShift template based deployments and repository orchestration
Stars: ✭ 51 (+218.75%)
Mutual labels:  jenkins, jenkins-pipeline
jenkins pipeline
A lean Continuous Deployment, Testing and Integration Pipeline using CoreOS/Docker/Jenkins
Stars: ✭ 44 (+175%)
Mutual labels:  jenkins, jenkins-pipeline
pipeline-maven-plugin
Pipeline Maven Plugin
Stars: ✭ 50 (+212.5%)
Mutual labels:  jenkins, jenkins-pipeline
movie-db-java-on-azure
Sample movie database app built using Java on Azure
Stars: ✭ 28 (+75%)
Mutual labels:  jenkins, jenkins-pipeline
jenkins-shared-library-example
Example for a Jenkins shared library with unit tests
Stars: ✭ 35 (+118.75%)
Mutual labels:  jenkins, jenkins-pipeline
jenkins-pipeline-shared-library-template
Project template for developing shared Jenkins pipeline libraries.
Stars: ✭ 46 (+187.5%)
Mutual labels:  jenkins, jenkins-pipeline
eryajf.github.io
📝 大千世界,何其茫茫。谨此笔记,记录过往。凭君阅览,小站洛荒。如能收益,莫大奢望
Stars: ✭ 159 (+893.75%)
Mutual labels:  jenkins, jenkins-pipeline
learn-ansible-and-jenkins-in-30-days
Ansible + Jenkins in 30 days tutorial.
Stars: ✭ 35 (+118.75%)
Mutual labels:  jenkins, jenkins-pipeline
jenkins-k8sagent-lib
Jenkins Shared Library to get dynamic agent from Kubernetes cloud
Stars: ✭ 35 (+118.75%)
Mutual labels:  jenkins, jenkins-pipeline
pipeline-lib
Global shared library for Glia pipeline jobs
Stars: ✭ 68 (+325%)
Mutual labels:  jenkins, jenkins-pipeline
jenny
Command line Jenkinsfile runner written in groovy. Does not need a Jenkins installation to run the Jenkinsfile.
Stars: ✭ 90 (+462.5%)
Mutual labels:  jenkins, jenkins-pipeline
pipeline-as-yaml-plugin
Jenkins Pipeline As Yaml Plugin
Stars: ✭ 111 (+593.75%)
Mutual labels:  jenkins, jenkins-pipeline
generator-mitosis
A micro-service infrastructure generator based on Yeoman/Chatbot, Kubernetes/Docker Swarm, Traefik, Ansible, Jenkins, Spark, Hadoop, Kafka, etc.
Stars: ✭ 78 (+387.5%)
Mutual labels:  jenkins
MasterSeleniumFramework
Automation Testing | Web | Java | OOPS | Selenium WebDriver | TestNG | Maven | ExtentReport | Allure Reports | Java mail API | Design Patterns (Page Object Model, Singleton) | Jenkins | Data-Driven Testing using JSON file
Stars: ✭ 52 (+225%)
Mutual labels:  jenkins
mirror-adapter
An adapter of Jenkins update center
Stars: ✭ 35 (+118.75%)
Mutual labels:  jenkins

Jenkins Pipeline

Jenkins Pipeline Shared Library. Contains helper functions to be used with the Jenkins Pipeline Plugin.

Image Class

The Docker Image class expects 3 or 4 arguments in its constructor call

# Type Required Description
1 Script Y A reference to the Script object, always this when instantiated from the Jenkinsfile.
2 String Y The name of the image, including the Docker Hub organization. i.e. invocaops/ruby.
3 String[] Y An array of tags to apply to the image.
String N The directory that the Dockerfile is in. Useful when multiple versions of the image need to be built. Defaults to the directory the Jenkinsfile is in.

Example

Example for Ruby 2.4.2, which is in a directory named 2.4.2 and being built from the master branch with SHA 12345:

image = new Image(this, "invocaops/ruby", ["2.4.2-12345", "2.4.2-master"], "2.4.2")

Usage

The Image class has 4 main methods to perform operations

Method Arguments Action
build() buildArgs (Map) Buils the Docker image.
tag() None Tags the image.
push() None Pushes the image and its tags to Docker Hub.

Each method returns a reference to the Image object, so chaining is possible.

Build Args

The Image#build method takes a Map of build arguments.

Argument Type Required Description
gitUrl     String Y URL to remote Git repository. Set to env.GIT_URL.
buildArgs Map       N foo=bar pairings for docker build --build-arg.
dockerFile String N Name of Dockerfile file, defaults to Dockerfile.
target String N Target stage to build to in the docker build.

Environment

In addition to the included Git environment variables, we currently assume access to credentials for DockerHub. You'll need to explicitly set these in your environment.

Variable Available By Default Description
DOCKERHUB_USER N Username for DockerHub.
DOCKERHUB_PASSWORD N Password for DockerHub.
GIT_COMMIT Y SHA of current build.
GIT_URL Y URL of GitHub repository being built.
GIT_BRANCH                   Y         The name of the checked out branch.

Getting Started

To use this library, start your Jenkinsfile with:

@Library('github.com/invoca/[email protected]')

After, parts of the library can be imported and used. Below is an example of a Jenkinsfile that builds multiple versions of the Ruby image.

@Library('github.com/invoca/[email protected]')

import com.invoca.docker.*;

pipeline {
  agent any
  stages {
    stage('Setup') {
      steps {
        script {
          def imageName = "invocaops/ruby"
          def directories = sh(script: 'ls **/Dockerfile | while read dir; do echo $(dirname $dir); done', returnStdout: true).split("\n")
          def sha = env.GIT_COMMIT
          def branchName = env.GIT_BRANCH

          images = directories.collect {
            String[] tags = ["${it}-${branchName}", "${it}-${sha}"]
            new Image(this, imageName, tags, it)
          }
        }
      }
    }

    stage('Build') {
      steps {
        script {
          for (Image image : images) {
            image.build(gitUrl: env.GIT_URL).tag()
          }
        }
      }
    }

    stage('Push') {
      environment {
        DOCKERHUB_USER = credentials('dockerhub_user')
        DOCKERHUB_PASSWORD = credentials('dockerhub_password')
      }
      steps {
        script {
          new Docker().hubLogin(env.DOCKERHUB_USER, env.DOCKERHUB_PASSWORD)
          for (Image image : images) {
            image.push()
          }
        }
      }
    }
  }

  post {
    always {
      notifySlack(currentBuild.result)
    }
  }
}

Please read more about libraries in the Jenkins documentation.

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].