It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

get bamboo project key using curl

phani phani Aug 24, 2014

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

0 votes
Answer accepted
Krystian Brazulewicz Atlassian Team Aug 26, 2014

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.

phani phani Aug 27, 2014

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.

0 votes
Krystian Brazulewicz Atlassian Team Aug 25, 2014

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?

Erik Husby Aug 25, 2014

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

0 votes
phani phani Aug 26, 2014

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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

4,447 views 21 23
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you