Jenkins - Do not post for a specific committer or commit message

I'm having problems with Jenkins and its Git plugin.

The Gitlab server is currently running builds, but I want to configure the task so that it does not build when a specific message is included in the commit.

I tried using the ci-skip plugin ( https://github.com/banyan/jenkins-ci-skip-plugin ), but instead of not starting the task, the plugin allows it but then cancels it.

It does the job, but I interrupted the build in the Jenkins story, and I try to avoid this.

Who succeeded?

+5
source share
3 answers

Jenkins git plugin itself already provides these kinds of extended use.

Exclude specific posts

Job configuration page -> Source Control -> Git -> Add -> Poll ignores commit with certain messages

Exclude specific commands

Job configuration page -> Source Control -> Git -> Add -> Poll ignores commits from specific users

Remember to click the help button at the end of each of them to find out the correct way to use it.

+6
source

If you have not found a solution:

  • Configure your job to poll SCM, but do not enter it for this (ignoring the warning that your work will never be completed.

  • Configure the scm section to ignore commits, users, etc.

  • Use a trigger for your jobs as follows: http://yourserver/git/notifyCommit?url=<URL of the Git repository>[&branches=branch1[,branch2]*][&sha1=<commit ID>] , as shown in Git Plugin page

Whenever the url is called, jenkins scans jobs that use this repository. Then it checks for any specific settings (for example, ignoring commits by some users or some commit messages) and either starts the build or not. Of course, the assembly will always somehow start scm polling and check for commits, but if it is canceled due to minor commits, you will not see the interrupted assembly in your history.

+1
source

You will need an external script.

Pull out the project (git clone / fetch) and then before continuing with the build check to see if a particular message is in your repository.

To check if your message is there, you can use the git show or git log commands.

git log

 git log --all --grep='<your message>' # and you can add more flags if you want of course: git log --all --oneline | grep '<your message>' 

git grep

 git grep '<your message>' $(git rev-list --all) 

Outside jenkins

Add code to the git hook , which checks that you want to find * messages, comment, etc.), and only if he finds it, will Jenkins call through the REST API and begin your work.

This is how I use Jenkins, I check something that I am looking for, and then im calls Jenkins via API

More here and here

0
source

Source: https://habr.com/ru/post/1237040/


All Articles