Artifact seems to be removed during source code checkout

David Rydgård
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!
November 2, 2023

I have an artifact dependency, the artifact being created by a previous stage in the plan. As 'destination directory' for the dependency, I have put 'Artifacts'.

There is a script task that just runs the line dir Artifacts. This works fine, and in the logs I can see that the artifact is in the 'Artifacts' directory. This task is followed by a source code checkout task. The source code checkout is then followed by a task which, again, just runs dir Artifacts. This time, it gives an error message because, as it seems, the 'Artifacts' directory does not exist anymore. 

I can see in the logs that, as part of the source code checkout, Bamboo "cleans" the build directory. I suppose this removes the 'Artifacts' directory. But if that is the case, how can I use Artifacts after doing a source code checkout?

2 answers

1 accepted

3 votes
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 2, 2023

Hello @David Rydgård

Welcome to the Atlassian Community!

There's a possibility the "Force Clean Build" property is enabled in the "Source Code Checkout" task, which will instruct the Agent to remove everything from the build-dir before running the Git checkout during Stage 2 execution.

Also, the Checkout Task in Bamboo will retry the operation in case of failure, like having files or folders in the checkout folder that are not part of the repository. When retrying, Bamboo cleans up the folder to have a clean checkout. That action may be removing the files you expect to see in the second stage. As you check out the code in place, there's a chance that Bamboo is doing that.

To fix that, set the "Checkout Directory" in the "Source Code Checkout" task properties to a subfolder within the build directory. That will allow you to separate the repository data from the artifacts, which will not conflict with files from a different stage.

It is also possible to remove the Artifact Dependency and add an "Artifact Download" task in the Second Stage Jobs so you can control exactly what and when artifacts will be downloaded.

More information can be found on the link below:

Thank you,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

David Rydgård
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!
November 2, 2023

Great, thank you for a clear explanation!

2 votes
Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 2, 2023

Hello David,

Welcome to Atlassian Community

I can understand you have the below structure for your plan.

1. First script task just runs the dir Artifacts which lists the artifcats from the build directory.

2. Source code checkout task checks out the repo

3. Third script task fails to list the directory.

You have mentioned that the script task is cleans the build directory, so we'll need to stop that. To do that you can go to the script task in your plan configuration and uncheck the option of "Force clean Build", see below

image.png

Let me know if this works for you.

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