From f2294ad4c37592d4046fd02e35439340278b09a0 Mon Sep 17 00:00:00 2001 From: Joel Baranick Date: Wed, 28 Oct 2015 12:54:10 -0700 Subject: Add support for plaintext username/password unless credentials are specified. --- .gitignore | 4 ++++ .../bitbucketpullrequestbuilder/BitbucketBuildTrigger.java | 14 ++++++++++++++ .../bitbucketpullrequestbuilder/BitbucketRepository.java | 11 +++++++++-- .../BitbucketBuildTrigger/config.jelly | 6 ++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c7b603 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +target +*.iml +.idea +dependency-reduced-pom.xml diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java index 974d3eb..09802af 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java @@ -32,6 +32,8 @@ public class BitbucketBuildTrigger extends Trigger> { private final String projectPath; private final String cron; private final String credentialsId; + private final String username; + private final String password; private final String repositoryOwner; private final String repositoryName; private final String ciSkipPhrases; @@ -48,6 +50,8 @@ public class BitbucketBuildTrigger extends Trigger> { String projectPath, String cron, String credentialsId, + String username, + String password, String repositoryOwner, String repositoryName, String ciSkipPhrases, @@ -58,6 +62,8 @@ public class BitbucketBuildTrigger extends Trigger> { this.projectPath = projectPath; this.cron = cron; this.credentialsId = credentialsId; + this.username = username; + this.password = password; this.repositoryOwner = repositoryOwner; this.repositoryName = repositoryName; this.ciSkipPhrases = ciSkipPhrases; @@ -77,6 +83,14 @@ public class BitbucketBuildTrigger extends Trigger> { return credentialsId; } + public String getUsername() { + return username; + } + + public String getPassword() { + return password; + } + public String getRepositoryOwner() { return repositoryOwner; } diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java index 8606c45..fb43f12 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java @@ -45,10 +45,17 @@ public class BitbucketRepository { public void init() { trigger = this.builder.getTrigger(); + String username = trigger.getUsername(); + String password = trigger.getPassword(); StandardUsernamePasswordCredentials credentials = getCredentials(trigger.getCredentialsId()); + if (credentials != null) { + username = credentials.getUsername(); + password = credentials.getPassword().getPlainText(); + } + client = new ApiClient( - credentials.getUsername(), - credentials.getPassword().getPlainText(), + username, + password, trigger.getRepositoryOwner(), trigger.getRepositoryName()); } diff --git a/src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly b/src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly index df43e5a..db5ca0f 100644 --- a/src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly +++ b/src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly @@ -5,6 +5,12 @@ + + + + + + -- cgit v1.2.3