bmuschko / gradle-cargo-plugin

Gradle plugin that provides deployment capabilities to local and remote containers via Cargo
Apache License 2.0
258 stars 63 forks source link

Glassfish/Payara : deployment order #209

Open morayKevin opened 1 year ago

morayKevin commented 1 year ago

Hi,

We use Jenkins to do deferred deployment of our applications on our production servers.

For this we use Gradle with the Cargo plugin (2.8.0)

It works very well but the deployment order is then reset to 100. This is highly problematic for some applications where this value is important.

my cargo task is

task deployOnGlassfish(type: CargoDeployRemote, dependsOn: validateBranch) {
  description = "Deploys WAR to Glassfish ."  // description of task
  containerId = 'glassfish5x'
  timeout = Duration.ofMinutes(2)
  hostname = "$fedris_test"
  protocol = 'https'
  port = 4848
  username = userLogin // username of tomcat
  password = userPassword  // password of the tomcat

  deployables = [
      new Deployable(files: files("""${rootProject.projectDir}\\build/libs/${applicationName}.war"""), context: """${glassfishApplicationName}""")
  ]
}

after contacting Payara support :

We reviewed the situation with the Cargo plugin, and the problem is that the Gradle version (the one you were using during the discussion on this ticket) is not supported by Codehaus directly, a third party developing the plugin independently. With the Maven version of the plugin we managed to get the deployment order working properly, but sadly we cannot do anything about the Gradle version. You will probably have to raise an issue on their Github page if you require the bug to be fixed.

So is it possible to do something about this?

THANKS

bmuschko commented 1 year ago

I doubt that the Payara meant to say "Gradle version". Gradle itself does not know anything about interacting with a Cargo. They likely meant the Cargo library version. Try to set the latest Cargo library version, as described here.

morayKevin commented 1 year ago

Using the instructions in the documentation of the plugin, I was not able to find a way to specify the deployment order and make it persist. Meanwhile, the Maven plugin for Cargo (Codehaus Cargo - Maven 3 Plugin) offers a way to specify a deployment order using the element in cargo.xml, by using the order attribute,

bmuschko commented 1 year ago

Can you give me a concrete example on how this achieved in the Maven plugin (optimally in XML)? I don't see anything about in the link you sent me.

morayKevin commented 1 year ago

Here is an example configuration on how to configure the deployment order using the Maven plugin:

<plugin> 
    <groupId>org.codehaus.cargo</groupId> 
    <artifactId>cargo-maven3-plugin</artifactId> 
    <version>1.10.6</version> 
    <configuration> 
      <container> 
        <containerId>payara</containerId> 
        <artifactInstaller> 
          <groupId>fish.payara.distributions</groupId> 
          <artifactId>payara</artifactId> 
          <version>5.2022.5</version> 
        </artifactInstaller> 
      </container> 
    <configuration> 
      <deployables> 
        <deployable> 
          <grroupId>${project.groupId}</groupId> 
          <artifactId>${project.artifactId}</artifactId> 
          <type>war</type> 
          <order>1</order> 
        </deployable> 
        <deployable> 
          <groupId>${project.groupId}</groupId> 
          <artifactId>MavenCargoTest2</artifactId> 
          <type>war</type> 
          <order>2</order> 
        </deployable> 
      </deployables> 
      <home>C:\payara-server\_WORKDIR\5.48.1\payara5\glassfish\domains\</home> 
      <properties> 
        <cargo.hostname>localhost</cargo.hostname> 
        <cargo.servlet.port>8080</cargo.servlet.port> 
        <cargo.glassfish.admin.port>4848</cargo.glassfish.admin.port> 
        <cargo.remote.username>admin</cargo.remote.username> 
        <cargo.remote.password>adminadmin</cargo.remote.password> 
        <cargo.glassfish.deploy.arg.remoteUpload>--upload=true</cargo.glassfish.deploy.arg.remoteUpload> 
      </properties> 
    </configuration> 
  </configuration>

  <!-- provides JSR88 client API to deploy on Payara --> 
  <dependencies> 
    <dependency> 
      <groupId>org.glassfish.main.deployment</groupId> 
      <artifactId>deployment-client</artifactId> 
      <version>5.0</version> 
    </dependency> 
  </dependencies> 
</plugin>

I hope this helps!

bmuschko commented 1 year ago

Thanks. The plugin uses the Cargo Ant tasks. I don't see anything in their documentation that would let you define a deployment order. You may want to ask on their mailing list.

Alternatively, you could probably set up individual CargoDeployRemote tasks, each of which deploys a single file. To produce the desired order, chain those task together with dependsOn.