SCP Task: Artifacts listed inconsistently

Bob Rzadzki
Contributor
May 24, 2022

I have a build plan that generates two artifacts: DEBUG and RELEASE.

In my deployment plan, I'm setting up 2 environments, DEV and PROD. Both use identical steps to move build results to a web server - one of these steps is an SCP task.

When I setup DEV, the only artififact available to the SCP task is DEBUG.

When I try to setup PROD, the only option is "ALL ARTIFACTS."

I've checked and both artifacts are created successfully and have content after the latest build. On the Deployment Project page, both artifacts are listed as available.

Why can't I select specific artifacts for one environment? Why is only one artifact selectable for the other environment?

3 answers

1 accepted

1 vote
Answer accepted
Angelo Pluskwa
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!
June 1, 2022

Just wanted to say, that we have exctly the same issue.

Angelo Pluskwa
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!
June 1, 2022

2022-06-01_13h53_02.png

In my case I forgot to configure individual artifact downloads.

Like Steffen Opel _Utoolity_ likes this
Bob Rzadzki
Contributor
June 2, 2022

This was it! I selected the specific artifact in the Artifact Download task and it became available in the SCP task.

Thanks, Angelo!

0 votes
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 26, 2022

hi, I was not able to reproduce issue. Applied your Specs to Bamboo 8.2.4 and everything looks ok. I can choose any artifact for any environment

Dev environment

Screenshot 2022-05-26 at 11.35.09.png

 

Production environment

Screenshot 2022-05-26 at 11.37.31.png

 

What if you try to achieve same config by Specs, does it work?

new Environment("Production")
.tasks(new CleanWorkingDirectoryTask(),
new ArtifactDownloaderTask()
.description("Download release contents")
.artifacts(new DownloadItem()
.artifact("Telescope Release Binary")),....
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 1, 2022

ok, I missed that problem was reported about Scp task, not Artifact download. I'll revisit this issue and check it again

0 votes
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 25, 2022

Hi, can you please share Specs code of your plan?

Bob Rzadzki
Contributor
May 25, 2022

Certainly, and thank you for your time.

import com.atlassian.bamboo.specs.api.BambooSpec;
import com.atlassian.bamboo.specs.api.builders.BambooKey;
import com.atlassian.bamboo.specs.api.builders.BambooOid;
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.permission.PlanPermissions;
import com.atlassian.bamboo.specs.api.builders.plan.Job;
import com.atlassian.bamboo.specs.api.builders.plan.Plan;
import com.atlassian.bamboo.specs.api.builders.plan.PlanIdentifier;
import com.atlassian.bamboo.specs.api.builders.plan.Stage;
import com.atlassian.bamboo.specs.api.builders.plan.artifact.Artifact;
import com.atlassian.bamboo.specs.api.builders.plan.branches.BranchCleanup;
import com.atlassian.bamboo.specs.api.builders.plan.branches.PlanBranchManagement;
import com.atlassian.bamboo.specs.api.builders.plan.configuration.ConcurrentBuilds;
import com.atlassian.bamboo.specs.api.builders.project.Project;
import com.atlassian.bamboo.specs.builders.task.CheckoutItem;
import com.atlassian.bamboo.specs.builders.task.CommandTask;
import com.atlassian.bamboo.specs.builders.task.ScriptTask;
import com.atlassian.bamboo.specs.builders.task.VcsCheckoutTask;
import com.atlassian.bamboo.specs.builders.trigger.BitbucketServerTrigger;
import com.atlassian.bamboo.specs.util.BambooServer;

@BambooSpec
public class PlanSpec {

public Plan plan() {
final Plan plan = new Plan(new Project()
.oid(new BambooOid("os4bi8q5wni9"))
.key(new BambooKey("TEL"))
.name("Telescope"),
"Build",
new BambooKey("BUILD"))
.oid(new BambooOid("orumancy2wox"))
.pluginConfigurations(new ConcurrentBuilds())
.stages(new Stage("Default Stage")
.jobs(new Job("Default Job",
new BambooKey("JOB1"))
.description("Builds both release and debug configs")
.artifacts(new Artifact()
.name("Telescope Release Binary")
.copyPattern("**")
.location("Telescope.Web/bin/Release/netcoreapp2.1/publish")
.shared(true)
.required(true),
new Artifact()
.name("Telescope Debug Binary")
.copyPattern("**")
.location("Telescope.Web/bin/Debug/netcoreapp2.1/publish")
.shared(true)
.required(true))
.tasks(new VcsCheckoutTask()
.description("Checkout Default Repository")
.checkoutItems(new CheckoutItem().defaultRepository()),
new ScriptTask()
.description("Install NPM packages")
.inlineBody("npm install")
.workingSubdirectory("Telescope.Web"),
new ScriptTask()
.description("Webpack React client")
.inlineBody("npm run build")
.workingSubdirectory("Telescope.Web"),
new CommandTask()
.description("Build release")
.executable("Build .NET 3.1")
.argument("publish -c Release Telescope.sln"),
new CommandTask()
.description("Build debug")
.executable("Build .NET 3.1")
.argument("publish -c Debug Telescope.sln"))))
.linkedRepositories("Telescope on Bitbucket")

.triggers(new BitbucketServerTrigger())
.planBranchManagement(new PlanBranchManagement()
.delete(new BranchCleanup())
.notificationForCommitters())
.forceStopHungBuilds();
return plan;
}

public PlanPermissions planPermission() {
final PlanPermissions planPermission = new PlanPermissions(new PlanIdentifier("TEL", "BUILD"))
.permissions(new Permissions()
.userPermissions("bob", PermissionType.EDIT, PermissionType.VIEW, PermissionType.ADMIN, PermissionType.CLONE, PermissionType.BUILD));
return planPermission;
}

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

final Plan plan = planSpec.plan();
bambooServer.publish(plan);

final PlanPermissions planPermission = planSpec.planPermission();
bambooServer.publish(planPermission);
}
}
Bob Rzadzki
Contributor
May 25, 2022
import com.atlassian.bamboo.specs.api.BambooSpec;
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.builders.task.ArtifactDownloaderTask;
import com.atlassian.bamboo.specs.builders.task.ArtifactItem;
import com.atlassian.bamboo.specs.builders.task.CleanWorkingDirectoryTask;
import com.atlassian.bamboo.specs.builders.task.DownloadItem;
import com.atlassian.bamboo.specs.builders.task.ScpTask;
import com.atlassian.bamboo.specs.builders.task.SshTask;
import com.atlassian.bamboo.specs.util.BambooServer;

@BambooSpec
public class PlanSpec {

public Deployment rootObject() {
final Deployment rootObject = new Deployment(new PlanIdentifier("TEL", "BUILD")
.oid(new BambooOid("orumancy2wox")),
"Deployment for Telescope")
.oid(new BambooOid("os73a4jnkkjl"))
.releaseNaming(new ReleaseNaming("release-3")
.autoIncrement(true))
.environments(new Environment("Dev")
.description("For daily development, updated with every commit")
.tasks(new CleanWorkingDirectoryTask(),
new ArtifactDownloaderTask()
.description("Download release contents")
.artifacts(new DownloadItem()
.artifact("Telescope Debug Binary")),
new SshTask()
.authenticateWithPassword("xxx")
.description("Clean deployment staging directory")
.host("x.x.x.x")
.username("username")
.command("if exist (D:\\temp\\deploy\\DEV del /q /s D:\\temp\\deploy\\DEV\\*) else ( mkdir D:\\temp\\deploy\\DEV\\ )"),
new ScpTask()
.description("Copy artifact to web server")
.host("x.x.x.x")
.username("username")
.toRemotePath("D:\\temp\\deploy\\DEV")
.authenticateWithPassword("xxx")
.fromArtifact(new ArtifactItem()
.sourcePlan(new PlanIdentifier("TEL", "BUILD"))
.artifact("Telescope Debug Binary")),
new SshTask()
.authenticateWithPassword("xxx")
.description("Move from deploy temp to deploy dir")
.host("x.x.x.x")
.username("username")
.command("D:/Deployment_helpers/polite-deploy.cmd telescope_dev D:/Deploy_staging/Telescope/DEV D:/usr/company_io/telescope_dev")),
new Environment("QA")
.tasks(new CleanWorkingDirectoryTask(),
new ArtifactDownloaderTask()
.description("Download release contents")
.artifacts(new DownloadItem()
.allArtifacts(true)),
new SshTask()
.authenticateWithPassword("xxx")
.description("Clean deployment staging directory")
.host("x.x.x.x")
.username("username")
.command("if exist (D:\\temp\\deploy\\QA del /q /s D:\\temp\\deploy\\QA\\*) else ( mkdir D:\\temp\\deploy\\QA\\ )"),
new ScpTask()
.description("Copy artifact to web server")
.host("x.x.x.x")
.username("username")
.toRemotePath("D:\\temp\\deploy\\QA")
.authenticateWithPassword("xxx")
.fromArtifact(new ArtifactItem()
.sourcePlan(new PlanIdentifier("TEL", "BUILD"))
.allArtifacts()),
new SshTask()
.authenticateWithPassword("xxx")
.description("Move from deploy temp to deploy dir")
.host("x.x.x.x")
.username("username")
.command("D:/Deployment_helpers/polite-deploy.cmd telescope_qa D:/Deploy_staging/Telescope/QA D:/usr/company_io/telescope_qa")),
new Environment("Staging")
.tasks(new CleanWorkingDirectoryTask(),
new ArtifactDownloaderTask()
.description("Download release contents")
.artifacts(new DownloadItem()
.allArtifacts(true)),
new SshTask()
.authenticateWithPassword("xxx")
.description("Clean deployment staging directory")
.host("x.x.x.x")
.username("username")
.command("if exist (D:\\temp\\deploy\\STAGING del /q /s D:\\temp\\deploy\\STAGING\\*) else ( mkdir D:\\temp\\deploy\\STAGING\\ )"),
new ScpTask()
.description("Copy artifact to web server")
.host("x.x.x.x")
.username("username")
.toRemotePath("D:\\temp\\deploy\\STAGING")
.authenticateWithPassword("xxx")
.fromArtifact(new ArtifactItem()
.sourcePlan(new PlanIdentifier("TEL", "BUILD"))
.allArtifacts()),
new SshTask()
.authenticateWithPassword("xxx")
.description("Move from deploy temp to deploy dir")
.host("x.x.x.x")
.username("username")
.command("D:/Deployment_helpers/polite-deploy.cmd telescope_staging D:/Deploy_staging/Telescope/STAGING D:/usr/company_io/telescope_staging")),
new Environment("Production")
.tasks(new CleanWorkingDirectoryTask(),
new ArtifactDownloaderTask()
.description("Download release contents")
.artifacts(new DownloadItem()
.allArtifacts(true)),
new SshTask()
.authenticateWithPassword("xxx")
.description("Clean deployment staging directory")
.host("x.x.x.x")
.username("username")
.command("if exist (D:\\temp\\deploy\\PRODUCTION del /q /s D:\\temp\\deploy\\PRODUCTION\\*) else ( mkdir D:\\temp\\deploy\\PRODUCTION\\ )"),
new ScpTask()
.description("Copy artifact to web server")
.host("x.x.x.x")
.username("username")
.toRemotePath("D:\\temp\\deploy\\PRODUCTION")
.authenticateWithPassword("xxx")
.fromArtifact(new ArtifactItem()
.sourcePlan(new PlanIdentifier("TEL", "BUILD"))
.allArtifacts()),
new SshTask()
.authenticateWithPassword("xxx")
.description("Move from deploy temp to deploy dir")
.host("x.x.x.x")
.username("username")
.command("D:/Deployment_helpers/polite-deploy.cmd telescope D:/Deploy_staging/Telescope/PRODUCTION D:/usr/company_io/telescope")));
return rootObject;
}

public DeploymentPermissions deploymentPermission() {
final DeploymentPermissions deploymentPermission = new DeploymentPermissions("Deployment for Telescope")
.permissions(new Permissions()
.userPermissions("username", PermissionType.EDIT, PermissionType.VIEW));
return deploymentPermission;
}

public EnvironmentPermissions environmentPermission1() {
final EnvironmentPermissions environmentPermission1 = new EnvironmentPermissions("Deployment for Telescope")
.environmentName("Dev")
.permissions(new Permissions()
.userPermissions("username", PermissionType.EDIT, PermissionType.VIEW, PermissionType.BUILD));
return environmentPermission1;
}

public EnvironmentPermissions environmentPermission2() {
final EnvironmentPermissions environmentPermission2 = new EnvironmentPermissions("Deployment for Telescope")
.environmentName("QA")
.permissions(new Permissions()
.userPermissions("username", PermissionType.EDIT, PermissionType.VIEW, PermissionType.BUILD));
return environmentPermission2;
}

public EnvironmentPermissions environmentPermission3() {
final EnvironmentPermissions environmentPermission3 = new EnvironmentPermissions("Deployment for Telescope")
.environmentName("Staging")
.permissions(new Permissions()
.userPermissions("username", PermissionType.EDIT, PermissionType.VIEW, PermissionType.BUILD));
return environmentPermission3;
}

public EnvironmentPermissions environmentPermission4() {
final EnvironmentPermissions environmentPermission4 = new EnvironmentPermissions("Deployment for Telescope")
.environmentName("Production")
.permissions(new Permissions()
.userPermissions("username", PermissionType.EDIT, PermissionType.VIEW, PermissionType.BUILD));
return environmentPermission4;
}

public static void main(String... argv) {
//By default credentials are read from the '.credentials' file.
BambooServer bambooServer = new BambooServer("https://bamboo.example.com");
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);

final EnvironmentPermissions environmentPermission2 = planSpec.environmentPermission2();
bambooServer.publish(environmentPermission2);

final EnvironmentPermissions environmentPermission3 = planSpec.environmentPermission3();
bambooServer.publish(environmentPermission3);

final EnvironmentPermissions environmentPermission4 = planSpec.environmentPermission4();
bambooServer.publish(environmentPermission4);
}
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events