ashwanthkumar / gocd-build-github-pull-requests

GoCD plugin to build PRs for a Github repo
94 stars 72 forks source link

Default branch doesn't work #148

Closed atharvai closed 4 years ago

atharvai commented 4 years ago

I have the following scenario:

  1. current repo using git material type with branch github_pr branch
  2. update material on github_pr branch to be pluggable scm (this github.pr plugin) for JSON plugin
  3. try pushing few commits to github_pr branch. notice GoCD and plugin recognises new commits. all good.
  4. change default branch to master and update config repo to read from master branch.
  5. commits on master branch or any others are not visible in GoCD. Trigger (without options) runs last commit from github_pr branch instead of master branch.

Question: Is there a way to clear cache for github scm type and repo? is there a way for the plugin to recognise different branch?

atharvai commented 4 years ago

here's obfuscated config

{
      "plugin_configuration": {
        "id": "github.pr",
        "version": "1.3.5"
      },
      "configuration": [
        {
          "key": "url",
          "value": "git@github.com:myrepo.git"
        },
        {
          "key": "defaultBranch",
          "value": "master"
        }
      ],
      "name": "myrepo",
      "type": "plugin"
ashwanthkumar-avalara commented 4 years ago

Default branch is only used for the initial run of the pipeline. Then on, the plugin would only recognise PR commits and build them. This is not a replacement for regular build pipeline. You're expected to have a regular build pipeline that builds the master or the primary branch in your repo.

atharvai commented 4 years ago

interesting. I wasn't aware of needing a separate pipeline. From a git perspective, master is just another branch. I could have called it anything else. Are you open to enabling primary branch builds via this plugin?

If the default branch is set to master, any PR merge commits will appear in GoCD to be triggered. so the PR "merge" commits could be executed as long as the very first trigger is based on primary branch.

Secondly, is there a way to clear the cache for the branch and start fresh for a given repository?

ashwanthkumar commented 4 years ago

So the gihub.pr doesn't build a given branch, it only builds open PRs that is by design.

Secondly, is there a way to clear the cache for the branch and start fresh for a given repository? I'm not sure I understand what you're asking there. Can you please explain it a bit more to me?

atharvai commented 4 years ago

I was trying this on an existing repository and pipeline so I created a branch github_pr and first triggered pipeline benchmarked the commit from this branch. After I merged to master, no new PRs were detected unless they were branched from github_pr.

atharvai commented 4 years ago

just to close off, the first time you create the material, set the default branch to master/main correctly. otherwise next time it will not work.