Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get an AnyTrigger to compile

jzajac2 September 20, 2023

I am writing PlanSpec.java for a build plan I have which contains After Deployment Triggers, however I cannot get it to compile. Here is a relevant portion of the code, apologies for the poor formatting:


  new AfterDeploymentTrigger()
.description("After test Prod Environment Deployment")
.deploymentProject("test")
.environment("prod")
*/
new AnyTrigger(new AtlassianModule("com.atlassianlab.bamboo.plugins.bamboo-after-deployment-trigger-plugin:afterDeployment"))
.name("After deployment")
.description("After test Prod Environment Deployment")
.configuration(new MapBuilder()
.put("deployment.trigger.afterDeployment.deploymentProjectId", "449904641")
.put("deployment.trigger.afterDeployment.deploymentEnvironmentId", "449118216")
.build()),

 
The compile error is:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project attcs-bamboo-plans: Compilation failure: Compilation failure: 
[ERROR] /bamboo-specs/src/main/java/deploymentevents/PlanSpec.java:[32,28] cannot find symbol
[ERROR] symbol: class plugins
[ERROR] location: package com.atlassian.bamboo
[ERROR] /bamboo-specs/src/main/java/deploymentevents/PlanSpec.java:[135,17] cannot find symbol
[ERROR] symbol: class AnyTrigger
[ERROR] location: class deploymentevents.PlanSpec
[ERROR] /bamboo-specs/src/main/java/deploymentevents/PlanSpec.java:[148,17] cannot find symbol
[ERROR] symbol: class AnyTrigger
[ERROR] location: class deploymentevents.PlanSpec
[ERROR] -> [Help 1]
[ERROR]



I have tried adding:

import com.atlassian.bamboo.plugins;

however, no change in behavior. 

I also do not understand the `Add com.atlassian.bamboo.plugins:afterdeployment-bamboo-specs:0.9 as dependency to your specs pom.xml to make use of this trigger builder.` comment. I have a colleague who believes I do not need to touch the pom.xml.

What am I missing to get this to compile? I used the View Plan As Java Specs option in bamboo for the above code. 
Thank you!

1 answer

0 votes
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 20, 2023

Hello @jzajac2

The After Deployment Trigger should be added to the Deployment Environment configuration and not to the Plan configuration.

The best way to find the required packages (and sample code) for that would be to create a Deployment Environment using the UI add the trigger there and later export it as Java Specs to understand what your requirements are.

Follow this path on your Environment configuration view:

  • ... >> View Project as Java Specs

Best regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

jzajac2 September 21, 2023

To clarify, I already have a working Plan configured manually via the UI. I am trying to write the specs for that, and I cannot get it to compile. I am already using the "View Project as Java Specs"

re: "The After Deployment Trigger should be added to the Deployment Environment configuration and not to the Plan configuration."

Are you saying that the "Default Plan Configuration | Triggers | Select trigger | After deployment" dialog in the UI, does not have a supported correlating Java Spec equivalent?

If it does, can you show me a simple code project Plan with Java Specs, demonstrating an After Deployment Trigger working?



Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 21, 2023

As I have mentioned:

The After Deployment Trigger should be added to the Deployment Environment configuration and not to the Plan configuration.

The way you are using it will not work in a Plan. You must add that configuration in your Deployment Environment.

Here's an example:

new Environment("OSALVA")
.description("DEP")
.tasks(new CleanWorkingDirectoryTask(),
new ScriptTask()
.inlineBody("echo hello world"),
.triggers(new AfterSuccessfulDeploymentTrigger("Deployment")
.name("After successful deployment")));

Cheers,

 

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events