How to create an artifact from my plugin Edited

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 vote

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.

 

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?

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?

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?

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,490 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you