<p>You want a <a href="https://en.wikipedia.org/wiki/Revision_Control_System" rel="nofollow noreferrer">RCS/VCS</a> that handles the version incrementally for you. I'm not sure how this relates to CI as the idea is to <a href="https://stackify.com/continuous-delivery-git-jenkins/" rel="nofollow noreferrer">Continuously Integrate</a> instead of spawning more branches. I'm not sure what you're using for your PR's, so I'll use Atlassian Bitbucket as an example. In the response to pushing up a new branch you get back the url for creating a PR which has an <a href="https://developer.atlassian.com/cloud/bitbucket/" rel="nofollow noreferrer">API which you can call to create your PR</a>.
Git commands will do the branching for you: </p>

<pre><code># Get the latest description, usually based on tags : https://git-scm.com/book/en/v2/Git-Basics-Tagging
$branchName = git describe
# Checkout the new branch 
git checkout -b $branchName
# Push up the branch to origin
git push --set-upstream origin feature/$branchName
</code></pre>

<p>It's best to have a firm grasp of git when dealing with VCS. 
* <a href="https://try.github.io/" rel="nofollow noreferrer">https://try.github.io/</a> 
* <a href="https://git-scm.com/book/en/v2/Getting-Started-Git-Basics" rel="nofollow noreferrer">https://git-scm.com/book/en/v2/Getting-Started-Git-Basics</a></p>

CC BY-SA 4.0
2019-01-03T04:40:43.883Z
For context, a developer other than me may be developing/merging a branch to project-A, but I'm the only one maintaining the files in repo-X. I'm looking not to offload that work to other developers, but rather to a script that performs a trivial update (e.g. text-replacement), commits the change to a branch, and creates a PR. I'd still want to manually review the PR, rather than trust 100% in the update script.
ivan
CC BY-SA 4.0
2019-01-03T05:30:15.567Z
Ok, not seeing where I mentioned that this would resolve the PR for you? GitHub api can create the PR for you (see [create a pull request](https://developer.github.com/v3/pulls/#create-a-pull-request)
lloyd
CC BY-SA 4.0
2019-01-03T01:32:49.017Z
2019-01-03T01:32:49.017Z
lloyd
<p>I am now starting to use the multi-branch pipeline and it looks really promising as it builds every branch that contains changes and a Jenkinsfile.</p>

<p><a href="https://wiki.jenkins.io/display/JENKINS/Pipeline+Multibranch+Plugin" rel="nofollow noreferrer">https://wiki.jenkins.io/display/JENKINS/Pipeline+Multibranch+Plugin</a></p>

CC BY-SA 4.0
2019-01-12T16:44:43.453Z
2019-01-12T16:44:43.453Z
030
<p>I have a repository (call it repo-X) of shell.nix files that define development environments for a number of separate projects (call them project-A, project-B).</p>

<p>When one of the projects releases a new version, I run a suite of automated tests in repo-X for the relevant shell.nix file, and if all goes well, I increment the version number in that file to match the new version of the project it supports.</p>

<p>I'd like to automate this process. I'm using Jenkins and GitHub to <em>build</em> PRs, but I'm not sure how I'd use CI to <em>author</em> a feature branch and create a corresponding PR.</p>

<p>I'm having a hard time even finding references/ideas, but maybe I'm searching for the wrong terms. What tooling should I look into for this?</p>

CC BY-SA 4.0
2019-02-11T23:19:07.733Z
i am using curl + github api to automatically create pull requests in a Jenkins pipeline.
les2
CC BY-SA 4.0
2019-02-11T23:21:13.220Z
in your scenario, I'll probably have project-A builds trigger project-X with parameters inside a jenkins pipeline. as you'll need to do the same thing in many repos, a shared pipeline library would be helpful.
les2
CC BY-SA 4.0
2019-01-03T17:28:30.210Z
I do this but with Bitbucket instead of Github.  Basically I just wrote down the steps that a dev would normally take to create a branch, update it, and open a PR, and put those steps in a Jenkinsfile.  The only difference is that Jenkins has to use the Bitbucket/Github API instead of the web interface to do the PR steps.  As long as the original process was CI-compatible, the automated process will be too.
jayhendren
<jenkins><continuous-integration><git><github>
Automate creation of branch + pull-request
ivan
# Automate creation of branch + pull-request

(Asked by: username_0 on 2019-01-02)

I have a repository (call it repo-X) of shell.nix files that define development environments for a number of separate projects (call them project-A, project-B).

When one of the projects releases a new version, I run a suite of automated tests in repo-X for the relevant shell.nix file, and if all goes well, I increment the version number in that file to match the new version of the project it supports.

I'd like to automate this process. I'm using Jenkins and GitHub to *build* PRs, but I'm not sure how I'd use CI to *author* a feature branch and create a corresponding PR.

I'm having a hard time even finding references/ideas, but maybe I'm searching for the wrong terms. What tooling should I look into for this?

**Tags:** jenkins, continuous-integration, git, github

> **Comments:**
> **username_2**: I do this but with Bitbucket instead of Github.  Basically I just wrote down the steps that a dev would normally take to create a branch, update it, and open a PR, and put those steps in a Jenkinsfile.  The only difference is that Jenkins has to use the Bitbucket/Github API instead of the web interface to do the PR steps.  As long as the original process was CI-compatible, the automated process will be too.  
> **username_1**: i am using curl + github api to automatically create pull requests in a Jenkins pipeline.  
> **username_1**: in your scenario, I'll probably have project-A builds trigger project-X with parameters inside a jenkins pipeline. as you'll need to do the same thing in many repos, a shared pipeline library would be helpful.  

---

## 2 answers

### Answer by username_3 on 2019-01-03. Score: 1

You want a RCS/VCS that handles the version incrementally for you. I'm not sure how this relates to CI as the idea is to Continuously Integrate instead of spawning more branches. I'm not sure what you're using for your PR's, so I'll use Atlassian Bitbucket as an example. In the response to pushing up a new branch you get back the url for creating a PR which has an API which you can call to create your PR.
Git commands will do the branching for you: 
# Get the latest description, usually based on tags : https://git-scm.com/book/en/v2/Git-Basics-Tagging
$branchName = git describe
# Checkout the new branch 
git checkout -b $branchName
# Push up the branch to origin
git push --set-upstream origin feature/$branchName

It's best to have a firm grasp of git when dealing with VCS. 
* https://try.github.io/ 
* https://git-scm.com/book/en/v2/Getting-Started-Git-Basics

> **Comments:**
> **username_0**: For context, a developer other than me may be developing/merging a branch to project-A, but I'm the only one maintaining the files in repo-X. I'm looking not to offload that work to other developers, but rather to a script that performs a trivial update (e.g. text-replacement), commits the change to a branch, and creates a PR. I'd still want to manually review the PR, rather than trust 100% in the update script.  
> **username_3**: Ok, not seeing where I mentioned that this would resolve the PR for you? GitHub api can create the PR for you (see [create a pull request](https://developer.github.com/v3/pulls/#create-a-pull-request)  

---

### Answer by username_4 on 2019-01-12. Score: 0

I am now starting to use the multi-branch pipeline and it looks really promising as it builds every branch that contains changes and a Jenkinsfile.

<https://wiki.jenkins.io/display/JENKINS/Pipeline+Multibranch+Plugin>


---

