Skip to content

Commit

Permalink
feat: load package configuration file and upload it with enterprisePa…
Browse files Browse the repository at this point in the history
…ckage target

Ref: MISC-446
  • Loading branch information
Obero committed Jan 30, 2024
1 parent 0439899 commit e0ba58f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<maven-gpg-plugin.version>3.1.0</maven-gpg-plugin.version>
<maven-surefire-plugin.version>3.1.0</maven-surefire-plugin.version>
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
<apache-commons-version>3.14.0</apache-commons-version>
</properties>

<dependencies>
Expand All @@ -78,6 +79,11 @@
<version>${maven3.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${apache-commons-version}</version>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-enterprise-plugin-commons</artifactId>
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/io/gatling/mojo/EnterpriseUploadMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
package io.gatling.mojo;

import io.gatling.plugin.BatchEnterprisePlugin;
import io.gatling.plugin.configuration.PackageConfiguration;
import io.gatling.plugin.exceptions.EnterprisePluginException;
import io.gatling.plugin.model.Pkg;
import java.io.File;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.Mojo;
Expand Down Expand Up @@ -51,6 +55,22 @@ public final class EnterpriseUploadMojo extends AbstractEnterprisePluginMojo {

@Override
public void execute() throws MojoFailureException {
final BatchEnterprisePlugin enterprisePlugin = initBatchEnterprisePlugin();

final String projectDirectory = mavenProject.getBasedir().getAbsolutePath();
final String jsonConfig = PackageConfiguration.loadToJson(projectDirectory);

if (StringUtils.isNotBlank(jsonConfig)) {
try {
getLog().info("Package configuration file detected, applying it.");
Pkg pkg = enterprisePlugin.uploadPackageConfiguration(jsonConfig);
packageId = pkg.id.toString();
getLog().info("Package id: " + packageId);
} catch (EnterprisePluginException e) {
throw new MojoFailureException("Failed to upload package configuration", e);
}
}

if (packageId == null && simulationId == null) {
final String msg =
"Missing packageID\n"
Expand All @@ -62,7 +82,6 @@ public void execute() throws MojoFailureException {
}

final File file = enterprisePackage();
final BatchEnterprisePlugin enterprisePlugin = initBatchEnterprisePlugin();

RecoverEnterprisePluginException.handle(
() ->
Expand Down

0 comments on commit e0ba58f

Please sign in to comment.