0

Git repo maintains origin/develop branch copy for develop branch.

git push origin develop from my laptop, sync up origin/develop branch

When I create a webhook(web integrations option) on GitLab portal with Jenkins, I see branches develop, master etc... but not origin\develop or origin/master.

I select develop branch and select "push events" and web hook

As per console log,

Checking out Revision 3fffffffffffffhjggjj3fffffffffffffhjggjj (refs/remotes/origin/develop) is shown in Jenkins, on webhook trigger,

for the corresponding groovy script git(branch: 'develop', credentialsId: credential, url: "${gitLabServer}/${projName}/${repoName}.git")


When user says, git push origin develop on his laptop,

Is webhook triggering jenkins pipeline on push event to origin/develop? Because I didn't create webhook for origin/develop... in pipeline I checkout code from develop branch

mohet
  • 151
  • 1
  • 4
  • 12
  • 1
    A normal `origin/develop` is a client-side branch. The webhooks does not care about the update of `origin/develop`. It is invoked by the push event that happens to the branch `develop` in the server-side repository. – ElpieKay Mar 07 '19 at 11:10
  • https://stackoverflow.com/questions/10588291/git-branching-master-vs-origin-master-vs-remotes-origin-master – phd Mar 07 '19 at 11:38
  • https://stackoverflow.com/questions/18137175/in-git-what-is-the-difference-between-origin-master-vs-origin-master – phd Mar 07 '19 at 11:38
  • https://stackoverflow.com/search?q=%5Bgit%5D+what+is+origin%2Fmaster – phd Mar 07 '19 at 11:38
  • @ElpieKay If webhooks does not care about `origin/develop`, then why would I see `Checking out Revision 3fffffffffffffhjggjj3fffffffffffffhjggjj (refs/remotes/origin/develop)` in console log of Jenkins, on webhook trigger? In groovy script, we write `git(branch: 'develop', credentialsId: credential, url: "${gitLabServer}/${projectName}/${repositoryName}.git") ` – mohet Mar 08 '19 at 15:13
  • @phd Query edited – mohet Mar 08 '19 at 15:18
  • @mohet the "origin/develop" you see in the jeninks log is from another client-side repo created by the jenkins job. Your repo updates local develop, push and update the develop in the remote repository. Then the webhook is invoked and trigger the jenkins job to create a local repo and fetch develop and then checkout its own origin/develop. – ElpieKay Mar 08 '19 at 15:20
  • @ElpieKay For your point: "fetch develop and then checkout its own origin/develop". Does fetching `develop` branch would not suffice? why to check out its own `origin/develop`? – mohet Mar 08 '19 at 17:11
  • Fetch `develop` so that its `origin/develop` is synced with `develop`. Checkout its updated `origin/develop` so that its work tree has the files and folders of the revision of `origin/develop`. – ElpieKay Mar 08 '19 at 17:23
  • @ElpieKay So, does `git(branch: 'develop', credentialsId: credential, url: "${gitLabServer}/${projectName}/${repositoryName}.git")` checkout both `develop` and `origin/develop` into Jenkins? – mohet Mar 08 '19 at 17:27
  • @mohet In your log, it checks out only `origin/develop`. But it does not matter if it's `develop` or `origin/develop` because both point to the same commit. – ElpieKay Mar 08 '19 at 17:38

1 Answers1

2

develop

develop is the branch on your machine/Jenkins server/any client.

origin

origin is the pointer to the location where your repository resides.

origin/develop

Complete path(location) of your develop branch on the repository.

when you are working on your development machine you will clone/fetch the repository and check out a particular branch to work on it say develop. once you finish your code you push it back to your repository by executing git push origin develop. This means you want to push your branch develop to origin and branch develop.

Coming to Jenkins integration, on Gitlab you are already on your repository and it has no other remote location to push so there won't be any concept of origin/develop where you are already on origin.

Harish Barma
  • 624
  • 8
  • 15
  • When you say: *push your branch develop to origin and branch develop*. Do you mean pushing local branch(`develop` branch in local repo) to only `develop` branch pointed by `origin` in remote repo? Do you mean pushing local branch(`develop` branch in local repo) to both `develop` branch in remote repo and `origin/develop` branch in remote repository? – mohet Mar 10 '19 at 01:28
  • Origin is the pointer to remote repository and develop is my branch. There is no branch origin/develop on remote. – Harish Barma Mar 11 '19 at 06:42
  • Origin/branch remote/branch these exists only on client side to point to a correct repository to push and pull code/anything – Harish Barma Mar 11 '19 at 06:43