diff options
author | Joel Baranick <joel.baranick@ensighten.com> | 2015-10-21 14:21:34 -0700 |
---|---|---|
committer | Joel Baranick <joel.baranick@ensighten.com> | 2015-10-21 14:21:34 -0700 |
commit | 8101c2fc7b6ca2b2fa1d835f2c5b2a5f159539a0 (patch) | |
tree | b3c1bbed511705fe1cef01570be2f3002240f520 /src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java | |
parent | d002e0b758c1907c2d4963a2b9e556177e05ab03 (diff) | |
download | bbprb-8101c2fc7b6ca2b2fa1d835f2c5b2a5f159539a0.tar.gz |
Support credentials by allowing UsernamePasswordCredentials to be picked when configuring BitbucketBuildTrigger and change BitbucketRepository to use the credentials when setting up the ApiClient.
Diffstat (limited to 'src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java')
-rw-r--r-- | src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java index 879facb..974d3eb 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java @@ -1,12 +1,17 @@ package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder; import antlr.ANTLRException; +import com.cloudbees.plugins.credentials.CredentialsProvider; +import com.cloudbees.plugins.credentials.common.StandardListBoxModel; +import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; +import com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials; import hudson.Extension; import hudson.model.*; import hudson.model.queue.QueueTaskFuture; import hudson.plugins.git.RevisionParameterAction; import hudson.triggers.Trigger; import hudson.triggers.TriggerDescriptor; +import hudson.util.ListBoxModel; import net.sf.json.JSONObject; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.StaplerRequest; @@ -17,6 +22,8 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; +import static com.cloudbees.plugins.credentials.CredentialsMatchers.instanceOf; + /** * Created by nishio */ @@ -24,8 +31,7 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> { private static final Logger logger = Logger.getLogger(BitbucketBuildTrigger.class.getName()); private final String projectPath; private final String cron; - private final String username; - private final String password; + private final String credentialsId; private final String repositoryOwner; private final String repositoryName; private final String ciSkipPhrases; @@ -41,8 +47,7 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> { public BitbucketBuildTrigger( String projectPath, String cron, - String username, - String password, + String credentialsId, String repositoryOwner, String repositoryName, String ciSkipPhrases, @@ -52,8 +57,7 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> { super(cron); this.projectPath = projectPath; this.cron = cron; - this.username = username; - this.password = password; + this.credentialsId = credentialsId; this.repositoryOwner = repositoryOwner; this.repositoryName = repositoryName; this.ciSkipPhrases = ciSkipPhrases; @@ -69,12 +73,8 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> { return this.cron; } - public String getUsername() { - return username; - } - - public String getPassword() { - return password; + public String getCredentialsId() { + return credentialsId; } public String getRepositoryOwner() { @@ -180,5 +180,12 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> { save(); return super.configure(req, json); } + + public ListBoxModel doFillCredentialsIdItems() { + return new StandardListBoxModel() + .withEmptySelection() + .withMatching(instanceOf(UsernamePasswordCredentials.class), + CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class)); + } } } |