Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
executable file 48 lines (44 sloc) 1.79 KB
* To be able to use the method exposed here, the following script signatures
* must be approved:
* method org.kohsuke.github.GHUser isMemberOf org.kohsuke.github.GHOrganization
* method org.kohsuke.github.GitHub getOrganization java.lang.String
* method org.kohsuke.github.GitHub getUser java.lang.String
* method org.kohsuke.github.GitHubBuilder build
* method org.kohsuke.github.GitHubBuilder withOAuthToken java.lang.String java.lang.String
* new org.kohsuke.github.GitHubBuilder
import org.kohsuke.github.GHOrganization
import org.kohsuke.github.GHUser
import org.kohsuke.github.GitHub
import org.kohsuke.github.GitHubBuilder
final boolean isOrgMember(String user, String org, String gitHubCredentialsId) {
node {
credentialsId: gitHubCredentialsId,
passwordVariable: 'GITHUB_PASSWORD',
usernameVariable: 'GITHUB_USERNAME')]) {
final GitHub gitHub = new GitHubBuilder()
final GHUser ghUser = gitHub.getUser(user)
final GHOrganization ghOrganization = gitHub.getOrganization(org)
return ghUser.isMemberOf(ghOrganization)
def call(String trustedOrg='fheng', String gitHubCredentialsId='githubjenkins') {
if (!env.CHANGE_AUTHOR) {
println "This doesn't look like a GitHub PR, continuing"
} else if (!isOrgMember(env.CHANGE_AUTHOR, trustedOrg, gitHubCredentialsId)) {
message: "Trusted approval needed for change from ${env.CHANGE_AUTHOR}",
submitter: 'authenticated'
} else {
println "${env.CHANGE_AUTHOR} is trusted, continuing"