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

How to create an artifact from my plugin

Amin Habash July 14, 2017

Hello,

I'm developing a plugin that creates files on the remote agent. I need to create an artifact and publish it in Bamboo.

1. How do I create the artifact? Is creating an ArtifactDefinition and an Artifact enough?

2. If so, how do I link the ArtifactDefinition to the Plan which runs my plugin? I'm unable to figure out how to get the "current plan".

3. Do I need to copy the files from the Agent to the server first? If so, how?

4. Do you have a simple code example that can help explain (In addition to answering the questions above)?

Please assist me as I've been struggling with this for so long and it's becoming quite urgent.

Thank you

1 answer

0 votes
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 14, 2017

If you're generating artifact it means build produces some file.

The best place to manage it is to create Task plugin which user adds to his build. Then user can configure his plan configuration and add Artifact definition.

 

Amin Habash July 14, 2017

Thank you for the quick response.

Regarding your answer, you mean to tell me that it's the user's responsibility to make sure that the artifacts are eventually published in Bamboo? This doesn't really make sense to me. Isn't there a way to do so code-wise?

Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 14, 2017

it's possible to create ArtifactDefinition programatically, bit it doesn't make sense to manage file upload from agent manually, Bamboo should do it. So artifact shoulb defined before build started and sent to agent. 

Can you describe the result you want to achieve with your plugin, what is business needs?

Amin Habash July 14, 2017

I'm creating a plugin for a program that runs a load test on the application the user specifies. It basically emulates a group of "virtual users" that access a web application and records the results. After the test run the results are saved on the agent, and that's where I'm stuck now.

I wanted to collect the result and publish them in Bamboo without having the user do any action manually. Is this possible?

Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 16, 2017

Ok, it's become a little clear now. Good way to handle this situation is to create artifact definition for build reacting on some user actions. 

As sample you can look at source code of Bamboo Clover plugin (it's part of Bamboo source code available for customers at my.atlassian.com). Plugin creates ArtifactDefinition for Clover report generated at agent side and then visible to user at additional tab of Build result. It's created when user enables Clover support for Job See com.atlassian.bamboo.clover.builder.coverage.CloverBuildProcessor#customizeBuildRequirements

 

ArtifactDefinitionImpl artifact = new ArtifactDefinitionImpl(CLOVER_REPORT_ARTIFACT_LABEL, reportDir, "**/*.*");
artifact.setProducerJob(job);

artifactDefinitionManager.saveArtifactDefinition(artifact);

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events