atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.34k stars 661 forks source link

Allow different selector types when triggering bitbucket pipeline #778

Open solveretur opened 3 years ago

solveretur commented 3 years ago

Currently when triggering pipeline the selector is hardcoded to be custom - https://github.com/atlassian-api/atlassian-python-api/blob/master/atlassian/bitbucket/cloud/repositories/pipelines.py#L54 - it causes that it's not possible to trigger pipeline by a tag.

Example case would be a bitbucket-pipelines.yml like this:

pipelines:
  default:
    - step:
        name: "Test and build"
        ...do something
    - step:
        name: "Deploy to test"
        ...do something
  tags:
    release-*:
    - step:
        name: "Test and build"
        ...do something
    - step:
        name: "Deploy to test"
        ...do something
    - step:
        name: "Deploy to prod"
        ...do something else

And I would like to trigger the release-* pipeline. It's possible by the rest api by just sending a request like:

{
  "target":{
    "type":"pipeline_ref_target",
    "ref_type":"branch",
    "ref_name":"master",
        "commit": {
            "type": "commit",
            "hash": "<SOME HASH>"
        },
    "selector":{
      "type":"tags",
      "pattern":"release-*"
    }
  }
}

but it's not possible while using your library.

Spacetown commented 3 years ago

If I get the docs right you can use this as pattern. I'm missing the enumeration of selector values in the docs. https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pipelines/#post