Skip to content

Commit

Permalink
[JENKINS-70746] Fix missing permission error when processing changes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
fredg02 authored Mar 20, 2023
1 parent b9560d6 commit dee7766
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
import com.cloudbees.plugins.credentials.common.StandardCredentials;
import com.cloudbees.plugins.credentials.common.StandardListBoxModel;
import com.cloudbees.plugins.credentials.domains.DomainRequirement;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
Expand All @@ -24,6 +25,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
Expand Down Expand Up @@ -374,9 +376,12 @@ public Secret getSecretToken() {

private StringCredentials getWebhookSecretCredentials(String webhookSecretCredentialsId) {
Jenkins jenkins = Jenkins.get();
jenkins.checkPermission(Jenkins.ADMINISTER);
return StringUtils.isBlank(webhookSecretCredentialsId) ? null : CredentialsMatchers.firstOrNull(
lookupCredentials(StringCredentials.class, jenkins),
return StringUtils.isBlank(webhookSecretCredentialsId) ? null
: CredentialsMatchers.firstOrNull(lookupCredentials(
StringCredentials.class,
jenkins,
ACL.SYSTEM,
new ArrayList<DomainRequirement>()),
withId(webhookSecretCredentialsId)
);
}
Expand Down

0 comments on commit dee7766

Please sign in to comment.