0

Below you can find my code to get all pipelines for a repository in BitBucket Cloud:

def get_pipelines(token, repo):
    """Return list of pipelines for repo"""
    full_pipeline_list = []
    next_page_url = f"https://api.bitbucket.org/2.0/repositories/{TEAM}/{repo}/pipelines/"

    headers = {"Accept": "application/json", "Authorization": f"Bearer {token}"}

    while next_page_url is not None:
        response = requests.request("GET", next_page_url, headers=headers, timeout=15)
        print(response)
        page_json = response.json()
        print(page_json)
        for repo in page_json["values"]:
            full_pipeline_list.append(repo)
        next_page_url = page_json.get("next", None)

    return full_pipeline_list

This isn't working because the "next" is absent in the output of my call. This is the response of a call. As you can see I have 124 pipeline executions. 10 are shown (I can show max 100 executions) but I can't use "next" to go to the next page.

{
'page': 1,
'pagelen': 10,
'values': [{...}],
'size': 124
}

Here you can find the API doc:

next string

Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs.

Format: uri

The next page should existing because I have 100+ executions. What am I missing or is this a bug?

DenCowboy
  • 13,884
  • 38
  • 114
  • 210

0 Answers0