Skip to content

Commit

Permalink
feat: implement enterpriseDeploy command, closes HYB-516
Browse files Browse the repository at this point in the history
  • Loading branch information
tpetillot committed Mar 27, 2024
1 parent fcd5d25 commit be640a4
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ githubPath := "gatling/gatling-sbt-plugin"

libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.18" % Test,
"io.gatling" % "gatling-enterprise-plugin-commons" % "1.9.0-M11"
"io.gatling" % "gatling-enterprise-plugin-commons" % "1.9.0-M13"
)

scriptedLaunchOpts := {
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/io/gatling/sbt/GatlingKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ object GatlingKeys {
|$documentationReference.
|""".stripMargin)

val enterpriseDeploy = taskKey[Unit]("Deploy a package and configured simulations")

val assembly = taskKey[File](
"Builds a package for Gatling Enterprise (deprecated, please use 'Gatling / enterprisePackage' or 'GatlingIt / enterprisePackage' instead)."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ object EnterpriseSettings {
val taskPackage = new TaskEnterprisePackage(config)
val taskUpload = new TaskEnterpriseUpload(config, taskPackage)
val taskStart = new TaskEnterpriseStart(config, taskPackage)
val taskDeploy = new TaskEnterpriseDeploy(config, taskPackage)

Seq(
config / enterpriseUrl := new URL("https://cloud.gatling.io"),
config / enterprisePackage := taskPackage.buildEnterprisePackage.value,
config / enterpriseUpload := taskUpload.uploadEnterprisePackage.value,
config / enterpriseStart := taskStart.enterpriseSimulationStart.evaluated,
config / enterpriseDeploy := taskDeploy.enterpriseDeploy.value,
config / enterprisePackageId := sys.props.get("gatling.enterprise.packageId").getOrElse(""),
config / enterpriseTeamId := sys.props.get("gatling.enterprise.teamId").getOrElse(""),
config / enterpriseSimulationId := sys.props.get("gatling.enterprise.simulationId").getOrElse(""),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2011-2024 GatlingCorp (https://gatling.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.gatling.sbt.settings.gatling

import scala.util.Try

import io.gatling.plugin.deployment.DeploymentConfiguration
import io.gatling.plugin.model.BuildTool
import io.gatling.sbt.BuildInfo
import io.gatling.sbt.GatlingKeys._
import io.gatling.sbt.settings.gatling.EnterpriseUtils.*

import sbt._
import sbt.Keys._

class TaskEnterpriseDeploy(config: Configuration, enterprisePackage: TaskEnterprisePackage) extends RecoverEnterprisePluginException(config) {
val enterpriseDeploy: InitializeTask[Unit] = Def.task {
val logger = streams.value.log
val enterprisePlugin = EnterprisePluginTask.batchEnterprisePluginTask(config).value
val packageFile = enterprisePackage.buildEnterprisePackage.value
val descriptorFile = DeploymentConfiguration.fromBaseDirectory((config / baseDirectory).value)
val artifactId = (config / name).value
val controlPlaneUrl = (config / enterpriseControlPlaneUrl).value

Try {
enterprisePlugin.deployFromDescriptor(
descriptorFile,
packageFile,
artifactId,
controlPlaneUrl.isDefined,
BuildTool.SBT,
BuildInfo.version
)
}.recoverWith(recoverEnterprisePluginException(logger)).get
}
}

0 comments on commit be640a4

Please sign in to comment.