0

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?

3
  • 1
    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
    Commented Jan 3, 2019 at 17:28
  • i am using curl + github api to automatically create pull requests in a Jenkins pipeline.
    – les2
    Commented Feb 11, 2019 at 23:19
  • 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
    Commented Feb 11, 2019 at 23:21

2 Answers 2

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

2
  • 1
    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
    Commented Jan 3, 2019 at 4:40
  • 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
    – lloyd
    Commented Jan 3, 2019 at 5:30
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.