How to execute module (PostBuildCompletedAction) after artifacts published and how to get artifacts

I'm writing a 'CustomPostBuildCompletedAction' module for bamboo and want it to run at the last possible second or at least after all artifacts have been published. Is there a "weight" attribute I can give to the xml descriptor for "PostBuildCompletedAction" or should I be using a different module altogether?

4 answers

1 accepted

1 vote

Try using SystemDirectory class methods to get to artifact directories.

Thanks. I was not aware this class existed. Much cleaner and fault-tolerant solution to grabbing the bamboo-home-dir than what I came up with.

The CustomBuildProcessorServer module does exactly this but I still can't seem to get to the artifacts in anyway. I tried using the BuildResultsSummaryManager and subsequently getting the ResultsSummary but exceptions are thrown trying to iterate over the Collection<AtrifactLink> (via getArtifactLinks()):

[INFO] [talledLocalContainer] net.sf.hibernate.LazyInitializationException: Fail

ed to lazily initialize a collection - no session or session was closed

This is odd considering the collection itself is non-null but attempting to iterate over it throws an exceptions. Is there anyway I can get at the artifacts from the CustomBuildProcessorServer module?

Following the advice from the below thread I was able to execute the necessary calls but the returned Collection<ArtifactLink> is of size 0. However at the time of execution the artifacts are clearly on disk so I'm not exactly sure why Bamboo is not picking this up. Is there a way to grab the artifact root directory somehow?

https://answers.atlassian.com/questions/66252/bamboo-api-lazy-init-exception-thrown-while-iterating-through-plans-and-build-results

To get the "artifact root" (because there was no way I could find to grab it through the API and it's related classes) directory I grabbed the "bamboo.home" property from system-properties and simply worked my way up to the relevant artifact directory using the plan-key, artifact-name, and artifact-file-name. Not sure if this is the correct way to go about things but it worked for my case.

EDIT: use of class SystemDirectory has all the classes one would need to find bamboo-home-dir

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
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,499 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