Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,883
Community Members
 
Community Events
176
Community Groups

In Bamboo, how can you determine which git commit generated a given build artifact?

I want work backwards from a build artifact (eg: .hex file from compiler output)  generated by Bamboo and find the associated .git commit reference used to build this artifact.

2 answers

2 votes

Hi @Phillip Matthews,

You could iterate over the JOB that published the artifact by consuming a REST API endpoint http://myhost.com:8085/rest/api/latest/result/{projectKey}-{buildKey}-{buildNumber : ([0-9]+)|(latest)} [GET]

As an example, you could run:

# replace USERNAME with a user who has VIEW permissions over given plan
# replace http://localhost:8085 with Bamboo's Base URL
# replace PROJ-PLAN-JOB1-1 with buildResultKey. Please refer to Bamboo Variables -
https://confluence.atlassian.com/x/nwQ_EQ - for more explanation

curl -k -u USERNAME \
-H 'Content-type: application/json' \
-H 'Accept: application/json' \
-X GET http://localhost:8085/rest/api/latest/result/PROJ-PLAN-JOB1-1?expand=vcsRevisions&expand=artifacts

As result, you will find the commit information under vcsRevisions.vcsRevision[max-result - 1].vcsRevisionKey:

{
    ...
    "vcsRevisions": {
        "size": 1,
        "expand": "vcsRevision",
        "vcsRevision": [
            {
                "repositoryId": 1605634,
                "repositoryName": "My Repository",
                "vcsRevisionKey": "defd4d397004415f683af6f356f59d77c04a9a10"
            }
        ],
        "start-index": 0,
        "max-result": 1
    }
    ...
}

and the artifacts available to build result under artifact[1] onward.

{
...
    "artifact": [
        {
            "name": "Build log",
            "link": {
                "href": "http://localhost:8085/download/PROJ-PLAN-JOB1/build_logs/PROJ-PLAN-JOB1-1.log",
                "rel": "self"
            },
            "producerJobKey": "PROJ-PLAN-JOB1-1",
            "shared": false
        },
        {
            "name": "TXT",
            "link": {
                "href": "http://localhost:8085/browse/PROJ-PLAN-1/artifact/shared/TXT/",
                "rel": "self"
            },
            "producerJobKey": "PROJ-PLAN-JOB1-1",
            "shared": true,
            "size": 31,
            "prettySizeDescription": "31 bytes"
        }
    ]
...
}

Please, refer to the following documentation for further information:

Hope the information provided help you somehow.

Kind regards,

Rafael

0 votes

There's build variable planRepository.1.revision which contains revision hash. You can use it to generate artifact name or content

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events