Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use jenkins git plugin to build from a branch include origin or not

When building from git on master jenkins fetches and uses origin/master. When building from git on a branch jenkins fetches and users mybranch not origin/mybranch and isn't picking up changes.

I switched the branch specifier to use origin/mybranch and it seems to work. Is the the standard way to handle things or am I missing a more obvious way of doing this? I don't want to add unecessary complexity.

Please let me know if jenkins should use origin/branchname instead of branchname for its Branches-To-Build field.

Thanks

Peter

like image 819
Peter Kahn Avatar asked Jun 27 '11 20:06

Peter Kahn


People also ask

What is the plugin of Git in Jenkins?

The git plugin provides Git Username and Password binding that allows authenticated git operations over HTTP and HTTPS protocols using command line git in a Pipeline job. The git credential bindings are accessible through the withCredentials step of the Credentials Binding plugin.

How do I pass a Git branch as parameter in Jenkins?

If you want to be able to dynamically give a Git branch to use in a Jenkins build then you'll need to do a couple of things. Then, in your Pipeline configuration, under Branches to build, add your parameter name inside the Branch Specifier box, surrounded by ${} . Jenkins will expand your variable when the job runs.

How do I run a Jenkins job from a Git repository?

Step 1: go to your GitHub repository and click on 'Settings'. Step 2: Click on Webhooks and then click on 'Add webhook'. Step 3: In the 'Payload URL' field, paste your Jenkins environment URL. At the end of this URL add /github-webhook/.


1 Answers

If you only have one remote repository (named origin), then entering branchname should be synonymous with entering origin/branchname. If you have multiple repositories and you just enter branchname then it should be checking all of the remote repositories for that branch.

Note that if you manually created a branch named branchname in the Jenkins workspace repository, then it may have slightly strange behavior, and you'll probably want to delete that branch or recreate the workspace. In general you should never manually manipulate the branches in the workspace repository.

It should never be trying to use local (non-remote) branches for polling or getting changes. If you are seeing it do this, then it's definitely a bug. You should try to upgrade your jenkins instance and git plugin to the newest version, and if you still see the problem you should file an issue (and in the meantime you could use origin/branchname as a workaround). However, entering just branchname works fine for me with the latest version, so if you continue to see this problem I would recommend you recreate the workspace to try to get a clean repository.

like image 71
Laepdjek Avatar answered Oct 13 '22 12:10

Laepdjek