Skip to content

Commit

Permalink
Set both Develocity and Gradle Enterprise Access Keys (#232)
Browse files Browse the repository at this point in the history
* Set both Develocity and Gradle Enterprise Access Keys

* Rephrase enforce url description to avoid apostrophe
  • Loading branch information
welandaz authored Nov 28, 2024
1 parent 258a486 commit 7495707
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/i18n/develocity-bamboo-plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ develocity.config.shared-credential-name=Shared credential name
develocity.config.access-key-info=The access key must be in the <b>&lt;server host name&gt;=&lt;access key&gt;</b> format. For more details please refer to the <a href="https://docs.gradle.com/enterprise/gradle-plugin/#manual_access_key_configuration" target="_blank">documentation</a>.
develocity.config.auto-injection-info=<div>To enable instrumentation for Gradle builds set the Develocity server URL and the desired version of the Develocity Gradle plugin.</div><div>To enable instrumentation for Maven builds set the Develocity server URL and select <em>Enables Develocity Maven extension auto-injection</em>.</div><div>For more details please refer to the <a href="https://github.com/gradle/develocity-bamboo-plugin#configuration" target="_blank">documentation</a>.</div>
develocity.config.enforce-url=Enforce Develocity server URL
develocity.config.enforce-url.description=Whether to enforce the Develocity server URL configured in this connection over a URL configured in the project's build.
develocity.config.enforce-url.description=Whether to enforce the Develocity server URL configured in this connection over the one in the project.
develocity.config.general.title=General settings
develocity.config.general.vcs-repository-filter=Auto-injection Git VCS repository filters
develocity.config.general.vcs-repository-filter.info=Newline-delimited set of rules in the form of +|-:repository_matching_keyword, for which to enable/disable Develocity Gradle plugin/Maven extension auto-injection.<br/>By default, all Git VCS repositories have auto-injection enabled.
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/gradle/develocity/bamboo/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public final class Constants {
// must have secret as part of the name, see com.atlassian.bamboo.util.PasswordMaskingUtils
public static final String ACCESS_KEY = "develocity.secret.accessKey";

public static final String DEVELOCITY_ACCESS_KEY = "GRADLE_ENTERPRISE_ACCESS_KEY";
public static final String DEVELOCITY_ACCESS_KEY = "DEVELOCITY_ACCESS_KEY";
public static final String GRADLE_ENTERPRISE_ACCESS_KEY = "GRADLE_ENTERPRISE_ACCESS_KEY";

public static final String SPACE = " ";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public void exportDevelocityAccessKey(BuildContext buildContext,
.stream()
.filter(setter -> setter.applies(task))
.findFirst()
.ifPresent(setter -> setter.apply(task, Constants.DEVELOCITY_ACCESS_KEY, accessKey))));
.ifPresent(setter -> {
setter.apply(task, Constants.DEVELOCITY_ACCESS_KEY, accessKey);
setter.apply(task, Constants.GRADLE_ENTERPRISE_ACCESS_KEY, accessKey);
})));
}

private boolean isDevelocityAccessKey(VariableDefinitionContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public void execute(@NotNull StageExecution stageExecution, @NotNull BuildContex
UsernameAndPassword credentials = credentialsProvider.findByName(sharedCredentialName).orElse(null);
if (credentials == null) {
LOGGER.warn(
"Shared credentials with the name {} are not found. Environment variable {} will not be set",
sharedCredentialName, Constants.DEVELOCITY_ACCESS_KEY
"Shared credentials with the name {} are not found. Environment variables {} and {} will not be set",
sharedCredentialName, Constants.DEVELOCITY_ACCESS_KEY, Constants.GRADLE_ENTERPRISE_ACCESS_KEY
);
return;
}
Expand All @@ -65,17 +65,17 @@ public void execute(@NotNull StageExecution stageExecution, @NotNull BuildContex
String accessKey = credentials.getPassword();
if (StringUtils.isBlank(accessKey)) {
LOGGER.warn(
"Shared credentials with the name {} do not have password set. Environment variable {} will not be set",
sharedCredentialName, Constants.DEVELOCITY_ACCESS_KEY
"Shared credentials with the name {} do not have password set. Environment variables {} and {} will not be set",
sharedCredentialName, Constants.DEVELOCITY_ACCESS_KEY, Constants.GRADLE_ENTERPRISE_ACCESS_KEY
);
return;
}

DevelocityAccessCredentials allKeys = DevelocityAccessCredentials.parse(accessKey);
if (allKeys.isEmpty()) {
LOGGER.warn(
"Cannot parse access keys from {} shared credential. Environment variable {} will not be set",
sharedCredentialName, Constants.DEVELOCITY_ACCESS_KEY
"Cannot parse access keys from {} shared credential. Environment variables {} and {} will not be set",
sharedCredentialName, Constants.DEVELOCITY_ACCESS_KEY, Constants.GRADLE_ENTERPRISE_ACCESS_KEY
);
return;
}
Expand Down

0 comments on commit 7495707

Please sign in to comment.