Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot use AnyTask in Deployments

Spencer Richman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 4, 2025

Hi,

I am attempting to migrate a deployment project to Java specs. We are using Bamboo 9.2.22. The deployment environments use tasks provided by JFrog's bamboo-artifactory-plugin. These tasks are exported by the plugin as AnyTasks. When scanning the specs repository, I am given the following error: 

04-Mar-2025 10:25:35	Task type com.atlassian.bamboo.specs.api.builders.task.AnyTask cannot be used in deployments

I cannot find any documentation on why this limitation exists or how one might work around it. Is there any way to work around this?

This is especially confusing because Bamboo will export the environment with AnyTasks, but then it cannot be imported. 

Thanks in advance!

2 answers

1 accepted

1 vote
Answer accepted
Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2025
It worked for me in Java specs as well, I am using the below specs in Bamboo 9.6.4

import com.atlassian.bamboo.specs.api.BambooSpec;
import com.atlassian.bamboo.specs.api.builders.AtlassianModule;
import com.atlassian.bamboo.specs.api.builders.BambooOid;
import com.atlassian.bamboo.specs.api.builders.deployment.Deployment;
import com.atlassian.bamboo.specs.api.builders.deployment.Environment;
import com.atlassian.bamboo.specs.api.builders.deployment.ReleaseNaming;
import com.atlassian.bamboo.specs.api.builders.permission.DeploymentPermissions;
import com.atlassian.bamboo.specs.api.builders.permission.EnvironmentPermissions;
import com.atlassian.bamboo.specs.api.builders.permission.PermissionType;
import com.atlassian.bamboo.specs.api.builders.permission.Permissions;
import com.atlassian.bamboo.specs.api.builders.plan.PlanIdentifier;
import com.atlassian.bamboo.specs.api.builders.task.AnyTask;
import com.atlassian.bamboo.specs.builders.task.ArtifactDownloaderTask;
import com.atlassian.bamboo.specs.builders.task.CleanWorkingDirectoryTask;
import com.atlassian.bamboo.specs.builders.task.DownloadItem;
import com.atlassian.bamboo.specs.builders.task.ScriptTask;
import com.atlassian.bamboo.specs.util.BambooServer;
import com.atlassian.bamboo.specs.util.MapBuilder;

@BambooSpec
public class PlanSpec {

public Deployment rootObject() {
final Deployment rootObject = new Deployment(new PlanIdentifier("SCRIP", "TIC1")
.oid(new BambooOid("xj6quyqtvy81")),
"DEPLOYMENTJAVA")
.oid(new BambooOid("xjj7ufxjdb0h"))
.releaseNaming(new ReleaseNaming("release-12")
.autoIncrement(true)
.applicableToBranches(true))
.environments(new Environment("UAT")
.tasks(new CleanWorkingDirectoryTask(),
new ArtifactDownloaderTask()
.description("Download release contents")
.artifacts(new DownloadItem()
.allArtifacts(true)),
new ScriptTask()
.inlineBody("ECHO \"test""),
new AnyTask(new AtlassianModule("org.jfrog.bamboo.bamboo-artifactory-plugin:ArtifactoryDeploymentDownloadTask"))
.configuration(new MapBuilder()
.put("artifactory.generic.publishBuildInfo", "")
.put("artifactory.generic.username", "")
.put("artifactory.generic.specSourceChoice", "jobConfiguration")
.put("artifactory.task.buildNumber", "")
.put("deployer.sharedCredentials", "")
.put("deployer.overrideCredentialsChoice", "")
.put("artifactory.task.buildName", "")
.put("artifactory.generic.resolveRepo", "")
.put("artifactory.generic.deployPattern", "")
.put("artifactory.generic.envVarsExcludePatterns", "")
.put("builder.artifactoryGenericBuilder.artifactoryServerId", "")
.put("artifactory.generic.file", "")
.put("resolver.overrideCredentialsChoice", "noOverriding")
.put("artifactory.generic.useSpecsChoice", "")
.put("artifactory.generic.includeEnvVars", "")
.put("artifactory.generic.artifactSpecs", "")
.put("artifactory.generic.password", "/* SENSITIVE INFORMATION */")
.put("artifactory.generic.jobConfiguration", "")
.put("baseUrl", "http://10.10.0.4:8085")
.put("artifactory.generic.envVarsIncludePatterns", "")
.put("artifactory.generic.resolvePattern", "")
.put("builder.artifactoryGenericBuilder.deployableRepo", "")
.put("captureBuildInfo", "")
.put("resolver.sharedCredentials", "")
.put("buildInfoAggregation", "")
.build()))
.releaseApprovalPrerequisite(Environment.ReleaseApprovalPrerequisite.NONE));
return rootObject;
}

public DeploymentPermissions deploymentPermission() {
final DeploymentPermissions deploymentPermission = new DeploymentPermissions("DEPLOYMENTJAVA")
.permissions(new Permissions()
.userPermissions("test", PermissionType.EDIT, PermissionType.VIEW_CONFIGURATION, PermissionType.VIEW, PermissionType.APPROVE_RELEASE));
return deploymentPermission;
}

public EnvironmentPermissions environmentPermission1() {
final EnvironmentPermissions environmentPermission1 = new EnvironmentPermissions("DEPLOYMENTJAVA")
.environmentName("UAT")
.permissions(new Permissions()
.userPermissions("test", PermissionType.EDIT, PermissionType.VIEW_CONFIGURATION, PermissionType.VIEW, PermissionType.BUILD));
return environmentPermission1;
}

public static void main(String... argv) {
//By default credentials are read from the '.credentials' file.
BambooServer bambooServer = new BambooServer("http://10.10.0.4:8085");
final PlanSpec planSpec = new PlanSpec();

final Deployment rootObject = planSpec.rootObject();
bambooServer.publish(rootObject);

final DeploymentPermissions deploymentPermission = planSpec.deploymentPermission();
bambooServer.publish(deploymentPermission);

final EnvironmentPermissions environmentPermission1 = planSpec.environmentPermission1();
bambooServer.publish(environmentPermission1);
}
}
Spencer Richman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 6, 2025

Thanks for checking, @Shashank Kumar! I guess it is a limitation that was resolved in a newer version. We will be upgrading to 9.6 soon so I will try again then. 

0 votes
Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2025

Hello Spencer,

Welcome to Atlassian community.

I tried a JFROG task in YAML specs on Bamboo 9.6.4 and it works, haven't tried yet on Java specs yet. Is it possible for you to give a try on YAML specs.

 

Regards,

Shashank kumar

**please don't forget to Accept the answer if your query was answered**

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events