Skip to content

Commit

Permalink
Merge pull request #63 from bluesliverx/master
Browse files Browse the repository at this point in the history
Add minimum permissions check for label trigger
  • Loading branch information
bluesliverx committed Apr 17, 2023
2 parents e96c665 + f58e235 commit 9ff13b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ protected void onEvent(GHEvent event, String payload) {
Pattern pattern = Pattern.compile(expectedLabel,
Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
if (pattern.matcher(label).matches()) {
if (!GithubHelper.isAuthorized(job, labellingAuthor, branchProp.getMinimumPermissions())) {

Check warning on line 150 in src/main/java/com/adobe/jenkins/github_pr_comment_build/IssueLabelGHEventSubscriber.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 150 is only partially covered, 2 branches are missing
continue;

Check warning on line 151 in src/main/java/com/adobe/jenkins/github_pr_comment_build/IssueLabelGHEventSubscriber.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 151 is not covered by tests
}
if (alreadyTriggeredJobs.add(job)) {
ParameterizedJobMixIn.scheduleBuild2(job, 0,
new CauseAction(new GitHubPullRequestLabelCause(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import hudson.Extension;
import hudson.model.Job;
import hudson.model.Run;
import jenkins.branch.BranchProperty;
import jenkins.branch.BranchPropertyDescriptor;
import jenkins.branch.JobDecorator;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* Allows a GitHub pull request comment to trigger an immediate build based on a comment string.
*/
public class TriggerPRLabelBranchProperty extends BranchProperty {
public class TriggerPRLabelBranchProperty extends TriggerBranchProperty {
/**
* The comment body to trigger a new build on.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
<f:entry title="gitHub label regex" field="label">
<f:textbox />
</f:entry>
<f:entry field="minimumPermissions" title="Minimum Permissions on repository to trigger the build">
<f:select default="WRITE" />
</f:entry>
</j:jelly>

0 comments on commit 9ff13b6

Please sign in to comment.