Coder Social home page Coder Social logo

codemc / scmskip-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from billygalbreath/scmskip-plugin

0.0 1.0 0.0 178 KB

Jenkins SCM Skip Plugin checks for a matching pattern in SCM commit message and aborts current build if it matches.

Home Page: https://wiki.jenkins.io/display/JENKINS/SCM+Skip+Plugin

License: MIT License

Java 100.00%

scmskip-plugin's Introduction

Jenkins SCM Skip Plugin

SCM Skip Plugin skips build triggered by SCM webhooks based on the commit message. If commit message matches given regular expression freestyle or pipeline build is skipped. Default regex is .*\[ci skip\].*, but can be overridden in global Jenkins configuration or on specific job/pipeline.

The plugin enables deletion of skipped builds. This feature is available for freestyle jobs and also for pipelines.

How it works

After SCM checkout SCM Skip plugin matches last commit message with regular expression. For freestyle jobs, the plugin integrates early into lifecycle after SCM checkout. Therefore, nothing is executed on a positive regex match.

For pipeline jobs, the plugin can be enabled as a pipeline step and currently cannot be executed earlier in the Jenkins build lifecycle.

If last commit message matches the pattern, the build is aborted (and deleted if enabled). For example, one of the matching messages would be:

  • Updated version. New version: 1.0.1 [ci skip]
  • [ci skip] Some changes
  • [ci skip]

Global Configuration

The regular expression can be set in Jenkins global configuration under "SCM Skip" section.

Jenkins Global Configuration

Enable on: freestyle job

On a freestyle job, the plugin can be enabled under the Environment section. Among other options, there is also a checkbox for "SCM Skip". After enabling plugin there are also options to override matching regex and enable deletion of skipped build. A sample configuration is depicted on an image below.

Job Configuration

Enable on: pipeline

When using pipeline with a Jenkinsfile syntax (declarative or scripted), the plugin can be enabled as a step in a stage with scmSkip step. The plugin can be included anywhere in pipeline, but it is recommended to include it as the first step. This way no other steps will be executed if the build is skipped. How to include the plugin in the pipeline is depicted on the image below. In the pipeline is also possible to override the regex pattern and enable build deletion. Both parameters are optional.

    pipeline {
        agent any
        
        stages {
            stage('Checkout') {
                steps {
                    scmSkip(deleteBuild: true, skipPattern:'.*\\[ci skip\\].*')
                }
            }
        }
    }

When overriding the skip pattern in pipeline descriptor, make sure special characters are properly escaped (e.g. "\").

Release notes

scmskip-plugin's People

Contributors

billygalbreath avatar plavc avatar zbynek avatar

Watchers

 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.