Skip to content

Commit

Permalink
feat: add private package support (#79)
Browse files Browse the repository at this point in the history
Motivation:
Private package support has been released on gatling enterprise.

Modifications:
Add control plane URL configuration in plugin configuration.

Result:
control plane url configuration leads the plugin to upload private package on the private repository.

Closes HYB-307
  • Loading branch information
bastien-gatling authored Aug 4, 2023
1 parent 98e9e4f commit 344a420
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
11 changes: 10 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ repositories {
}

dependencies {
implementation "io.gatling:gatling-enterprise-plugin-commons:1.5.5"
implementation "io.gatling:gatling-enterprise-plugin-commons:1.6.0"
implementation "org.apache.ant:ant:1.10.11"
constraints {
implementation('com.fasterxml.jackson.core:jackson-databind') {
version {
strictly '2.14.3'
}
because 'some gradle versions have bug with multi-jdk jar, introduced in jackson-databind 2.15.' +
'cf. https://github.com/gradle/gradle/issues/24390'
}
}

testImplementation('org.spockframework:spock-core:1.3-groovy-2.5') {
exclude module: 'groovy-all'
Expand Down
18 changes: 17 additions & 1 deletion src/main/groovy/io/gatling/gradle/GatlingPluginExtension.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class GatlingPluginExtension {
private static final String SYSTEM_PROPS_PROPERTY = "gatling.enterprise.systemProps"
private static final String ENVIRONMENT_VARIABLES_PROPERTY = "gatling.enterprise.environmentVariables"
private static final String WAIT_FOR_RUN_END_PROPERTY = "gatling.enterprise.waitForRunEnd"
private static final String PRIVATE_CONTROL_PLANE_URL = "gatling.enterprise.privateControlPlaneUrl"
private static final String PLUGIN_NAME = "gatling-gradle-plugin"

final static class Enterprise {
Expand All @@ -42,6 +43,7 @@ class GatlingPluginExtension {
private String simulationClass
private boolean batchMode
private boolean waitForRunEnd
private URL privateControlPlaneUrl

def setBatchMode(boolean batchMode) {
this.batchMode = batchMode
Expand Down Expand Up @@ -139,6 +141,14 @@ class GatlingPluginExtension {
setWaitForRunEnd(waitForRunEnd)
}

def setPrivateControlPlaneUrl(String privateControlPlaneUrl) {
this.privateControlPlaneUrl = new URL(privateControlPlaneUrl)
}

def privateControlPlaneUrl(String privateControlPlaneUrl) {
setPrivateControlPlaneUrl(privateControlPlaneUrl)
}

@Input
@Optional
UUID getSimulationId() {
Expand Down Expand Up @@ -226,6 +236,12 @@ class GatlingPluginExtension {
return waitForRunEnd || Boolean.getBoolean(WAIT_FOR_RUN_END_PROPERTY)
}

@Input
@Optional
URL getprivateControlPlaneUrl() {
return privateControlPlaneUrl ?: new URL(System.getProperty(PRIVATE_CONTROL_PLANE_URL))
}

EnterpriseClient initEnterpriseClient(String version) {
def apiToken = getApiToken()
if (!apiToken) {
Expand All @@ -239,7 +255,7 @@ class GatlingPluginExtension {
}

try {
return new HttpEnterpriseClient(getUrl(), getApiToken(), PLUGIN_NAME, version)
return new HttpEnterpriseClient(getUrl(), getApiToken(), PLUGIN_NAME, version, getprivateControlPlaneUrl())
} catch (UnsupportedClientException e) {
throw new InvalidUserDataException(
"Please update the Gatling Gradle plugin to the latest version for compatibility with Gatling Enterprise. See https://gatling.io/docs/gatling/reference/current/extensions/gradle_plugin/ for more information about this plugin.",
Expand Down

0 comments on commit 344a420

Please sign in to comment.