简体   繁体   中英

how to create pull request if jenkins job running on feature branch is successful

Is there a Jenkins plugin for creating pull requests?

Suppose I am running a Jenkins job on some feature branch. If this job is successful, then I want Jenkins to automatically create a pull request from this feature branch.

There is a command-line way to create pull requests:

git request-pull [-p] <start> <url> [<end>]

but I haven't been able to find a way to get Jenkins to automate the task.

Your Jenkins job can have a step calling the Atlassian Stash API for creating a pull request

POST /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests?direction&at&state&order&withAttributes&withProperties 

Create a new pull request between two branches. The branches may be in the same repository, or different ones. When using different repositories, they must still be in the same {@link Repository#getHierarchyId() hierarchy} .

The authenticated user must have REPO_READ permission for the " from " and " to " repositories to call this resource.

It is more typical to go the other way: users choose when they are ready to create a pull request, and Jenkins (or any other CI tool) updates the status of the pull request based on the project build result. For example, if you use the GitHub Pull Request Builder, then Jenkins will send a message to GitHub when the project build starts and can close the pull request automatically if the build fails.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM