How to use Bamboo's rest api to download an artifact - rest

I am trying to write a bash script to download an artifact from Bamboo so that it can be used for other operations. I tried following the solution suggested in this post - using bamboo/rest/api/latest/result however I still just get the xml showing the location and the name of the artifact. The artifact itself is not downloaded. Any suggestions on how to go about this?
Below is the api cmd that I am using:
http://myhost.com:8085/bamboo/rest/api/latest/result/{projectKey}-{buildKey} [GET]

After much tweaking I managed to get it to work. I had messed up parsing of the artifact location link extracted from the xml. With the correct link, obtained from the xml, and the right authentication the artifact can be downloaded.

Related

List files of a build artifact

I've seen that in the 5.0 preview of the REST API it seems possible to download a specific file from a build artifact using :
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName={artifactName}&fileId={fileId}&fileName={fileName}&api-version=5.0-preview.5
But how to list the files of an artifact ? I don't know what to input for fileId.
My usecase is a folder archived as an artifact during the build. I would like to get download links for each files in the folder.
I found that the API you using is not having complete documentation.
I used below to download specific file from Build artifacts using PowerShell. You could get the container ID from GET build details.
https://$collectionurl/tfs/$teamproject/_apis/resources/Containers/$containerID?itemPath=drop%filename.txt

Retrieve a downloadTicket for an artifact in VSTS

I am trying to obtain a "publicly accessible" link for the artifact produced during the build process. The API does reference something called a downloadTicket but the API call doesn't seem to return anything related. I understand that the download would need to provide the downloadTicket through a header, but for now, my question is:
What call do I need to make, either through the REST API or within a
build task itself, to get the artifact information, including the
downloadTicket?
Or option two, is there something else I can to avoid uploading
the file to Azure blob, etc.?
Why do you have to retrieve the downloadTicket?
If you just want to download the artifacts you can use the REST API - Artifacts - Get to retrieve the downloadUrl, then you can share and use that URL to download the specific artifact. (Pleas note that the users need the correct permission to view/download build artifacts)
"downloadUrl": "https://{account}.visualstudio.com/{project}/_apis/build/builds/235/artifacts?artifactName=drop&api-version=5.0-preview.3&%24format=zip"
If you want to download the artifacts in build/release process, then you can use Download Build Artifacts task.
For your option 2, you can create a share location then select a file share as the Artifact publish location and specify the share location. Thus the artifacts will be published to the shared folder... You can set the share folder to "publicly accessible"...

Retrieve build info of a SNAPSHOT jar from artifactory using gradle

Before going forward, I realize this question is too broad. But I couldn't figure out the proper verbiage to search either here in SO or on GOOGLE.
If this question is a duplicate, then please excuse me in advance and provide me the link to the original question.
Problem :
We are working on creating testing framework. One of the requirements is to publish a report at the end of the testing phase with build information. We need to provide information like who committed the latest change we are testing, what is the build version we are using for testing etc.
In our current setup, We are using github as SCM. Whenever there is a commit to the SCM, a build is triggered on Jenkins and if the build is successful, the jar is deployed to JFrog Artifactory. I am trying to come up with a gradle script to get the necessary information.
Any pointers to the following questions are highly appreciated:
Which plugin can I use to retrieve the info for a SNAPSHOT jar from Artifactory?
Which plugin can I use to retrieve Jenkins build info using the build number retrieved from Q1?
Not sure this is what you were asking for, but have you looked into the Artifactory Build Info file?
The Artifactory Jenkins Plugin can collect build information for you and publish that information to the Artifactory server (If you choose to "collect and publish build info").
The build information can then be viewed on the artifactory server and also fetched using a simple REST call.
HTH,
Or

Get Jenkins artifacts URl from REST api

Is there any way to get artifacts download url from jenkins REST API. I am using artifact deployer and artifacts can be download from
http://localhost:8080/job/jobname/buildId/deployedartifact/downloads/artifacts.{id}
Is it possible to get the url infomation from REST api??
you mean this?
http://jenkins/job/myjob/../api/json?tree=artifacts[*]
Reference:
Click here
If you're using the ArtifactDeployer Plugin, then, unfortunately, the artifacts deployed through it won't be listed by the API.
The ideal solution, if you have the time for it, would be to mod the plugin and add an API to it.
In my case, due to time constraints, I had to scrape the page instead, by fetching the build's HTML page and picking up all the <a> tags whose href started with "deployedartifact/downloads".

Can I download artifacts built by BuildHive?

I have started using the free Jenkins build service on BuildHive for one of my GitHub projects. This is also my first try doing anything with Maven. I have succeeded in building my project using this script on BuildHive:
cd base_dir
mvn package
The build log shows that the resulting JAR has been built. Now I would like to offer the JAR to my project's users as a download artifact because GitHub has discontinued the feature of manually uploading binaries in a separate download section.
Is there any way I can download an artifact, referencing it by a URL? If so, how do I construct the URL, knowing only the artifact's local path from the build log?
Alternatively, is there a way in which I can push the artifact to another place by adding a command to my build shell script after mvn package? I was thinking of something like a curl or ftpput commmand.
The best thing I was able to come up with as a quick workaround was to upload the artifacts in question to my FTP server via curl, as suggested by my original question. It works, but the downside are the FTP credentials in the build public log. I have counterbalanced that by a shell script on my DSL router which checks for FTP storage abuse every few minutes.
As an alternative I found that after creating a free CloudBees account for my little open source project, I got my own Jenkins build configuration as well as my own artifact repository where to deploy my build artifacts. This is much more elegant and does not involve posting any FTP credentials to a public server.
I am still open for BuildHive-only solutions if anyone has a smart idea. :-)