[SOLVED] Clone from git not reflecting change in commit

Some setup details:

  • Github Enterprise 2.10.X
  • Drone 0.7 and 0.8
  • Build image: ruby:alpine

Scenario:

  • Changes to Ruby scripts in the root of the repo are not reflected in the build execution even though the commits from GHE and Drone are mapping correctly.

This could definitely be addressed in another issue/topic. I did check Github.com and discourse for similar topics. I didn’t find anything - could totally be based on search terms.

basic drone.yml: (edited some items, like secret name values)

    ---
      pipeline:
        build:
          image: ruby:alpine
          secrets: [something_login, something_token, something_else_token]
          commands:
            - bundle install
            - ruby users.rb

When I change the users.rb file, the commit to Github Enterprise triggers a push to Drone. When Drone does a clone, the users.rb file change from the commit isn’t reflected in the Drone execution.

For example, I have a “puts ‘abc’” in the users.rb file. The initial commit and triggered build executes but the change to the file isn’t reflected in the actual build - for example, ‘abc’ isn’t in the output from the Ruby script being executed. If I restart the build multiple times, eventually (without a change to the source) the output will reflect the update to the repo.

A commit to the actual drone.yml file always show correctly during the build. I’ve added things like “- echo done” to the commands section and the output of the build reflects.

I don’t have direct access to logs but can get there if/as needed.

1 Like

I can confirm this issue. Adding a little more info, it only happens when pushing commits to an open pull request from a forked repo. It does not occur when building commits from the repo itself.

This could definitely be addressed in another issue/topic. I did check Github.com and discourse for similar topics

The existing issue can be found in the git plugin repository, since cloning is delegated to plugins. I do appreciate you searching and posting the question here first. Thanks!

it only happens when pushing commits to an open pull request from a forked repo. It does not occur when building commits from the repo itself.

Yes, there is a known issue with pull requests caused by the fact that GitHub will trigger a hook before the merge commit is ready. The git plugin uses the merge ref to clone your repository, which means if the merge commit is not ready, the git clone may not include your changeset.

The recommend solution (aside from github fixing what I consider a bug) is to configure drone to use the head ref instead of the merge ref. This can be configured with the following flag:

DRONE_GITHUB_MERGE_REF=false

I have been meaning to change the default to head ref, making the merge ref opt-in. I think this is a better default, especially now that github supports protected branches with enforced synchronization.

2 Likes

The change on the server side did the trick. Thanks for the quick response!

1 Like