¿Cómo construir la nueva rama enviada a github usando Jenkins CI?

I've setup the Jenkins for the rails3 app to build the specs. One can find many posts via google on how to setup the build trigger on the github push.

But what I want is to build the new remote branch pushed to Github. e.g.

I've a repo origin/master. I cloned the repo, created a new branch, did some commits and pushed that branch to origin git push -u origin new_branch

Now I want the Jenkins to build this newly pushed branch on the origin.

If the build is successful, then Jenkins should merge it into origin/master automáticamente.

The Jenkins plugin has github, git plugin. But it requires to put the branch name. Instead I want to build the new_branch dynamically.

How can I setup such process?

preguntado el 08 de noviembre de 11 a las 12:11

Esta pregunta ya tiene una respuesta aquí: stackoverflow.com/a/39884629/4124574 -

2 Respuestas

If I remember correctly branch name is not a required entry. You need to test it, but I think if you do not fill it, Jenkins tests all new commit in the repo regardless which branch is affected.

But I recommend you do not merge automatically. You do not want that, trust me. :-)

contestado el 14 de mayo de 12 a las 01:05

So if it's already passed the tests from the build, what's wrong with merging to master? - Jordania

The problem is post-build actions runs always even if tests failed. And Jenkins currently do not have a merge-back option for git so you need to run it from shell script at post-build action. - Gabor Garami

Not sure which version of the Post-Build you're using, but mine has an option to trigger when the build is stable. I use the "Trigger Parameterized Build" plugin, which has a superset of the functionality as the regular Trigger Build plugin. - Jordania

So, if you're executing your shell scripts with -e, then it will exit immediately upon test failures, and will set your entire build to failed. - Jordania

@Jordan yes if you run shell scripts. But it is not always true - Gabor Garami

It seems can not do that with only github and gitgub parameter plugin. If you specify branch_regex*** in Branch to build, Jenkins always build the latest commit in the bunch of branches that it saw. Must specify a branch in order Jenkins to build on the latest commit in that branch. I also see some answer with Multi Branch Pipeline but not sure how to deploy that way. There is no specific instruction at all.

Respondido 21 Oct 20, 08:10

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.