Skip to content

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

License

Notifications You must be signed in to change notification settings

jenkinsci/scmskip-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 all commit messages 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 all the 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]

Example of non skipped build. In this case one of the checkins is not meant to be skipped, so the build is not aborted:

  • Updated version. New version: 1.0.1 [ci skip]
  • BUG-135 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. "\").

About

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

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Languages