Script to pull all build plans in Bamboo API

Greetings experts, I need a bit of help here. I have two API calls to Bamboo, one pulls a listing of all projects, the other pulls the build plan. However, what I’m wanting to do is list out all the project keys and query each one for its build plan. The API calls I use are:

List All Projects: http://{ServerName}/rest/api/latest/project?max-result=160
Export Build Plan: http://{ServerName}/rest/api/latest/project/{ProjectKey}/specs?max-result=160

How does one loop through this structure? Anyone done this before?

Hi @dbrewerton. Welcome to the Postman Community!

This is very possible in Postman. You’ll need to customize your request run and loop over certain requests. We’ve documented how to go about this in our learning center here.

Please let me know if you have any further questions.

That looks promising. Now, how do I pull the value projectKey from the bamboo api call in Postman where it loops through each projectKey and calls the API for the job information?
Query First Project by projectKey
Enter loop to query job information based on projectKey
Repeat until projectKey is null

You can do that by writing scripts in Postman. The scripts tab gives you access to your API response.

  • Query the List ALL projects Endpoint
  • Write a Script to Extract all Projects Keys
  • Store the project keys in a Collection/Environment Variable so you can keep track of keys you’ve run a build against.
  • Write a logic to run a different request responsible for querying the build plan
  • In that request, check if there are any project keys left in your project key variable. If there are, use pm.setNextRequest to itself and loop over that request as specified in the resource shared earlier.
  • Remember to remove keys you’ve run against in your environment variable.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.