github-plugin icon indicating copy to clipboard operation
github-plugin copied to clipboard

Ignorable pusher

Open aderigs opened this issue 9 years ago • 20 comments

This defines a regular expression to which the name or email of an ignorable pusher is to be matched. Such a push will be ignored. Normally a preceding push of Jenkins him self could be prevented that way.

Review on Reviewable

aderigs avatar Jun 23 '15 09:06 aderigs

This should work and be configured in GIT scm configuration.

KostyaSha avatar Jun 23 '15 09:06 KostyaSha

How would you do this? The only possibility I have found would be something like "Polling ignores commits from certain users". But this would involve committers but not pushers.

aderigs avatar Jun 23 '15 10:06 aderigs

@KostyaSha:

Wrong. You are confusing this with the existing featue of ignoring a commit-author. The pusher is not necessarily the committer!

felfert avatar Jun 23 '15 10:06 felfert

Thank you for a pull request! Please check this document for how the Jenkins project handles pull requests

jenkinsadmin avatar Jun 23 '15 12:06 jenkinsadmin

Hi I think this PR solve this issue: https://issues.jenkins-ci.org/browse/JENKINS-24208 I missed this PR and I create another one https://github.com/jenkinsci/github-plugin/pull/83 (probably more basic then this one)

@KostyaSha It can not be done in GIT scm configuration, have look at jira comment.

Anyway if you can validate this PR or mine, it's critical for our jenkins/github dev. pipeline

Regards Christophe

ouaibsky avatar Sep 08 '15 07:09 ouaibsky

When this should be merged?

igreenfield avatar Feb 08 '16 10:02 igreenfield

This will be never merged it current state, because of it provides only one case of filtering push (there is same for branches, committers, titles). But it still open because of its a good idea and not bad implementation. But we beed some more common implementation of filtering feature.

You can use hpi from the jenkins build to use this custom implementation (thanks @aderigs for rebasing)

lanwen avatar Feb 08 '16 14:02 lanwen

What about using the Run Condition Plugin to support all kinds of filtering?

igreenfield avatar Feb 08 '16 14:02 igreenfield

You can solve this issue by using intermediate decider job that can do additional verification and trigger real builds. Pushers need to be implemented in more generic security API. API will be clear when you implement all possible gh triggers. I started this work in https://github.com/jenkinsci/github-integration-plugin .

@lanwen on other hand this 'hook -> gitscm poll' trigger wouldn't fit in any good APIs so probably such feature may be added to this trigger. But everything should be localised somewhere in code unique to this trigger.

KostyaSha avatar Feb 08 '16 16:02 KostyaSha

Keeping in mind that gh utilises git polling log i can suggest try set exclusions using git configuration features (i.e. user exclusions). It wouldn't use gh names, but should work fine if people setting right names in git commits.

KostyaSha avatar Feb 08 '16 16:02 KostyaSha

When I install the plugin with this change I don't see where to configure the new configuration!

igreenfield avatar Feb 09 '16 12:02 igreenfield

Yes. The last version has introduced src/main/resources/com/cloudbees/jenkins/GitHubPushTrigger/config.groovy which hides src/main/resources/com/cloudbees/jenkins/GitHubPushTrigger/config.jelly. I think the clean way would be to migrate config.jelly into the new config.groovy. But I do not know how to do this.

aderigs avatar Feb 09 '16 14:02 aderigs

the groovy file should be:

package com.cisco.jenkins.GitHubPushTrigger

import com.cisco.jenkins.GitHubPushTrigger

def f = namespace(lib.FormTagLib);

tr {
    td(colspan: 4) {
        f.entry(title: _("Ignorable Pusher"), field: "ignorablePusher") {
            f.textbox()
        }
    }
}

script(src: "${rootURL}${h.getResourcePath()}/plugin/github/js/warning.js")
script {
    text("""
InlineWarning.setup({ 
    id: 'gh-hooks-warn',
    url: ${descriptor.getCheckMethod('hookRegistered').toCheckUrl()}, 
    input: 'input[name="${GitHubPushTrigger.class.getName().replace(".", "-")}"]'
}).start();
""")
}

igreenfield avatar Feb 09 '16 20:02 igreenfield

Codecov Report

Merging #58 into master will increase coverage by 0.01%. The diff coverage is 73.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #58      +/-   ##
==========================================
+ Coverage   75.07%   75.08%   +0.01%     
==========================================
  Files          64       64              
  Lines        1412     1425      +13     
  Branches      146      149       +3     
==========================================
+ Hits         1060     1070      +10     
+ Misses        307      306       -1     
- Partials       45       49       +4
Impacted Files Coverage Δ
...bhook/subscriber/DefaultPushGHEventSubscriber.java 82.14% <66.66%> (ø) :arrow_up:
.../java/com/cloudbees/jenkins/GitHubPushTrigger.java 61.24% <75%> (+0.89%) :arrow_up:
src/main/java/com/cloudbees/jenkins/Cleaner.java 22.22% <0%> (+5.55%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c7927b4...b1d8812. Read the comment docs.

codecov-io avatar Jul 24 '16 08:07 codecov-io

Please rebase and not merge

KostyaSha avatar Aug 21 '16 00:08 KostyaSha

@KostyaSha, it's why I did

git pull --rebase origin master

But don't know why, sounds not working, maybe missing some settings ?

ouaibsky avatar Aug 21 '16 10:08 ouaibsky

That message to @aderigs who owns this PR

KostyaSha avatar Aug 21 '16 10:08 KostyaSha

Does this support ignoring specific commit messages as well?

kdawgwilk avatar Aug 24 '16 16:08 kdawgwilk

No. It ignores the pusher by name or email. If you want to ignore by specific commit messages you could use the git-plugin.

aderigs avatar Aug 28 '16 17:08 aderigs

I have not been able to find a solution for this using the github folder plugin, which manages webhooks, and I believe uses this plugin. It automatically sets up the job and doesn't give you anywhere to configure the SCM that was setup. I just need a way to ignore webhook triggers if a specific commit message exists. I was hoping this would solve the issue :(

kdawgwilk avatar Aug 29 '16 02:08 kdawgwilk