ldeng
ldeng

Reputation: 23

How to create Pull Request on stash(Bitbucket Server) by jenkins plugins or command lines

I've installed Stash pullrequest builder plugin. This plugin is used to build Pull Request by reading the official introduction.

But I wanna know whether this plugin will create a specific Pull Request on stash. If not, how could I create by other plugins or by command lines or manually on stash?

Upvotes: 2

Views: 2541

Answers (1)

Bruno Lavit
Bruno Lavit

Reputation: 10382

You can use the Stash REST API to create a pull request with a command line.

You have to send a json post request to this url:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests

Example with Curl:

curl -u your_stash_user:your_stash_password -H "Content-Type: application/json" -X POST -d '{JSON CONTENT}' http://your_stash_url/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests

Json file (copied from the Atlassian doc):

{
    "title": "Talking Nerdy",
    "description": "It’s a kludge, but put the tuple from the database in the cache.",
    "state": "OPEN",
    "open": true,
    "closed": false,
    "fromRef": {
        "id": "refs/heads/feature-ABC-123",
        "repository": {
            "slug": "my-repo",
            "name": null,
            "project": {
                "key": "PRJ"
            }
        }
    },
    "toRef": {
        "id": "refs/heads/master",
        "repository": {
            "slug": "my-repo",
            "name": null,
            "project": {
                "key": "PRJ"
            }
        }
    },
    "locked": false,
    "reviewers": [
        {
            "user": {
                "name": "charlie"
            }
        }
    ]
}

Upvotes: 4

Related Questions