How to wait until artifact uploading is complete and available from Jenkins pipeline?

264 views
Skip to first unread message

Ian Boudreaux

unread,
Mar 1, 2023, 4:41:08 PM3/1/23
to Jenkins Users
Hi,

We are using the Jenkins archiveArtifacts step with the Azure Artifact manager plugin to store our artifacts in an Azure storage account. 

When we archive large artifacts using the archiveArtifacts step, it takes ~15 minutes for our artifacts to be uploaded and visible on Jenkins.

However, the archiveArtifacts step completes instantly and does not cause the pipeline to wait until that artifact is visible. This causes issues because other downstream pipelines use the artifacts from that pipeline and because the pipeline is completing successfully and not waiting until the artifact is actually available through Jenkins, the downstream pipelines are failing.

TLDR: My question is how can we force this Jenkins pipeline to wait until that artifact is actually visible and available through Jenkins before it completes as successful?

Thanks!
Ian

Ian Boudreaux

unread,
Mar 1, 2023, 7:27:09 PM3/1/23
to Jenkins Users
For anyone else that stumbles across this question, I figured it out. I used the following code snippet to ensure the Jenkins pipeline waits until it sees the artifact before completing the pipeline run so that if any downstream jobs see the success, they can assume that the artifact is readily available through Jenkins.

            echo('Waiting for build artifact to upload to Azure...')
            while (!currentBuild.getRawBuild().getArtifacts().toString().contains("<your-build-artifact>"));
            echo('Build artifact uploaded successfully')

Thanks!

christop...@googlemail.com

unread,
Mar 2, 2023, 2:14:31 PM3/2/23
to Jenkins Users
I'd add something like a sleep to the loop....

BR,
Christoph

Baptiste Mathus

unread,
Mar 3, 2023, 3:15:09 AM3/3/23
to jenkins...@googlegroups.com
If the step really returns before being done, it sounds like a bug you wanna report. 

As usual, your best bet to get it fixed if you really need this soon is to consider filing the PR yourself, or considering some paid bounty to motivate someone else :-).

Cheers

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ab9e4410-78e9-4911-b854-b21dda31a691n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages