Skip to content

Commit

Permalink
Fix not retaining credentialid (#2)
Browse files Browse the repository at this point in the history
* Fix: credentialId was not retained in config

Fixes ingenieux#4

Steps to reproduce:

1. specify credentialId in configure page
2. save
3. reload page
4. credentialId has gone, but should still be there

* Fix: no getter found for repositoryName

Exception is thrown when trying to export the configuration of this
plugin using the Jenkins CasC plugin.

* Fix: make it possible to use CodeCommitHelper for a Shared Library

Co-authored-by: Tobia De Koninck <tobia.dekoninck@openanalytics.eu>
  • Loading branch information
matt2005 and LEDfan authored Jan 20, 2022
1 parent ee82d32 commit 2886222
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,23 @@
*/
public class CodeCommitURLHelper extends GitSCMExtension {
private String credentialId;
private String repositoryName;

@DataBoundConstructor
public CodeCommitURLHelper(String credentialId, String repositoryName) {
this.credentialId = credentialId;
this.repositoryName = repositoryName;
}

public String getCredentialId() {
return this.credentialId;
}

public String getRepositoryName() {
return this.repositoryName;
}


private static final class RepositoryUsernameReference {
private final UsernamePasswordCredentialsImpl credential;

Expand Down Expand Up @@ -199,15 +210,20 @@ public String getDisplayName() {

public AbstractIdCredentialsListBoxModel<?, ?> doFillCredentialIdItems(
@AncestorInPath Item owner) {
if (owner == null || !owner.hasPermission(Item.CONFIGURE)) {

if (owner != null && !owner.hasPermission(Item.CONFIGURE)) {
return new AWSCredentialsListBoxModel();
}

List<AmazonWebServicesCredentials>
creds =
CredentialsProvider
List<AmazonWebServicesCredentials> creds;
if (owner == null) {
// no owner (e.g. no Job), this happens on the "Configure System" page when adding a Global Library
creds = CredentialsProvider.lookupCredentials(AmazonWebServicesCredentials.class);
} else {
creds = CredentialsProvider
.lookupCredentials(AmazonWebServicesCredentials.class, owner, ACL.SYSTEM,
Collections.<DomainRequirement>emptyList());
}

return new AWSCredentialsListBoxModel()
.withEmptySelection()
Expand All @@ -228,4 +244,3 @@ protected String describe(@NonNull AmazonWebServicesCredentials c) {
}
}
}

0 comments on commit 2886222

Please sign in to comment.