get bamboo project key using curl

Here is what I am trying to do:

If I query Bamboo Project name to Bamboo REST API using Curl , Expected output is: Project Key.

If I query Bamboo Plan Name to Bamboo REST API using Curl , Expected output is: plan key.

3 answers

1 accepted

This widget could not be displayed.

For this particular scenario I'd query Bamboo REST to list all plans:

$BAMBOO_URL/rest/api/latest/plan

and then use the information from response (plan key + plan name) to populate your UI controls. Then you'll display plan name and store plan key.

Yes, thats what I did. But the problem with this method is... if a project is having more than 40 plans, I have write a script to basically iterate all plans to get a key for a plan.

Since this is simple query, thought there would a direct solution for it.

But, thanks for your Inputs.

This widget could not be displayed.

Hi

The whole REST API is build the other way around. You're exepected to know the project/plan key and then you can get more detailed information. Example for plan BAM-FC:

curl --header "Accept: application/json" $BAMBOO_URL/rest/api/latest/plan/BAM-FC

will give you

{
    "expand": "actions,stages,branches,variableContext",
    "projectKey": "BAM",
    "projectName": "+core+ Bamboo",
    "project": {
        "key": "BAM",
        "name": "+core+ Bamboo",
        "link": {
            "href": "$BAMBOO_URL/rest/api/latest/project/BAM",
            "rel": "self"
        }
    },
    "description": "Our main CI test build.",
    "shortName": "A CI Tests Master",
    "buildName": "A CI Tests Master",
    "shortKey": "FC",
    "type": "chain",
    "enabled": true,
    "link": {
        "href": "$BAMBOO_URL/rest/api/latest/plan/BAM-FC",
        "rel": "self"
    },
    "isFavourite": false,
    "isActive": false,
    "isBuilding": false,
    "averageBuildTimeInSeconds": 3627,
    "actions": {
        "size": 1,
        "start-index": 0,
        "max-result": 1
    },
    "stages": {
        "size": 2,
        "start-index": 0,
        "max-result": 2
    },
    "branches": {
        "size": 25,
        "start-index": 0,
        "max-result": 25
    },
    "variableContext": {
        "size": 30,
        "max-results": 30
    },
    "key": "BAM-FC",
    "name": "+core+ Bamboo - A CI Tests Master",
    "planKey": {
        "key": "BAM-FC"
    }
}

Can you please explain why would you like to query REST API with plan name?

One good reason -- Bamboo does not display the Project/Plan keys any where except in the build log files.

This widget could not be displayed.

Its hard to explain, but try to put this way, my JIRA ticket is accepting two fileds that are related to Bamboo (1. Project Name 2. Plan Name). I am writing a script to auto execute the Bamboo Plan, based on the JIRA Ticket. For this I had to build a Bamboo Plan url (based on the Project Name or Plan Name that I am capturing from JIRA Ticket) which requires Bamboo Plan Key.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

264 views 1 3
Join discussion

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