GithubHelp home page GithubHelp logo

lunaticare / jenkins-pipeline-goodness Goto Github PK

View Code? Open in Web Editor NEW

This project forked from doublescoring/jenkins-pipeline-goodness

0.0 3.0 0.0 29 KB

License: Apache License 2.0

Groovy 99.87% Dockerfile 0.13%

jenkins-pipeline-goodness's Introduction

jenkins-pipeline-goodness Build Status

Daily usage Jenkins Pipeline utilities covered by JUnit tests.

Basic usage

In your Jenkninsfile

#!groovy

node {
    def docker
    String version

    stage("checkout code") {
        // checkout your code here or there ...

        // and then:
        checkout([$class                           : 'GitSCM',
                  extensions                       : [[$class           : 'RelativeTargetDirectory',
                                                       relativeTargetDir: 'jenkins-pipeline-goodness'],
                                                      [$class           : 'CleanCheckout']],
                  userRemoteConfigs                : [[url: '[email protected]:doublescoring/jenkins-pipeline-goodness.git']], // Jenkins Pipeline Goodness url
                  branches                         : [[name: 'refs/tags/1.1.1']]]) // Jenkins Pipeline Goodness version
    }
    docker = load "jenkins-pipeline-goodness/src/main/groovy/docker.groovy" // attach docker module
    try {
        stage("build image") {
            dir('path/to/your/dockerfile/') {
                def dockerFileContent = readFile('Dockerfile')
                version = docker.readVersion(dockerFileContent)
                echo "Found version in Dockerfile ${version}"
                docker.imageBuildPush("organization/name", version, "latest", "our-private-registry:12345")
            }
        }
    } finally {
        if (something_exists_that_we_must_clean) {
            docker.stopById(dockerContainerId);
            docker.removeImage("organization/name", version);
        }
    }
}

Utilities

  • exec - Execute command inside docker image
  • imageBuildPush - Build a docker image, tag it, and push to repo
  • run - Run a docker image, wait the TCP port to be ready, return container Id
  • removeImage - Remove image from repo
  • stopById - Stop docker container.
  • readVersion - Read LABEL version="n.n.n" from Dockerfile
  • temporaryFile - Get temporary file

Tests

mvn test - for all tests

mvn -Dtest=environmentTest test - for environment tests

Versioning Guidelines

This project follow Apache rules of semantic versioning. Use git tags of the current project.

CONTRIBUTORS

  • Alexey Aksenov

LICENSE

The Jenkins Pipeline Goodness Project is licensed to you under the terms of the Apache License, version 2.0, a copy of which has been included in the LICENSE file. Please check the individual source files for details.

Copyright

Copyright © 2016 DoubleData Ltd. All rights reserved.

Apache License

jenkins-pipeline-goodness's People

Contributors

ezh avatar lunaticare avatar shuva10v avatar

Watchers

 avatar  avatar  avatar

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.