Code checkout artifacts missing git refs if triggered by PR update vs. branch update (OD-2497)
doubleplusc opened 6 months ago

I currently have .onedev-buildspec.yml set up so that on a PR or branch change, it'll trigger a job.

However, I'm getting a failure on the PR job trigger. PR #2 and branch pr-trigger-fail are for the same code, so I think it's a bug that they're behaving differently.

My code checkout step publishes all artifacts.

- name: code checkout
  steps:
  - !CheckoutStep
    name: checkout
    cloneCredential: !DefaultCredential {}
    withLfs: false
    withSubmodules: true
    condition: SUCCESSFUL
    optional: false
  - !PublishArtifactStep
    name: artifacts
    artifacts: '**'
    condition: SUCCESSFUL
    optional: false

image.png

As a result, when I use the git repo in the next step, I get the error below.

13:03:18 ERROR Failed to read Git log: fatal: not a git repository (or any parent up to mount point /)
13:03:18 Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
13:03:22 Total in 3365 ms

I chased it down to the .git directory missing .git/logs/refs and .git/refs. Why would these differ for the exact same repo on the same branch? To me it looks like the refs aren't getting included in the artifacts. Appreciate all guidance on the matter.

image_2.png

  • Robin Shen commented 6 months ago

    Can you please attach an example project demonstrating this issue?

  • doubleplusc commented 6 months ago

    Made an example project and was able to reproduce the issue. The project doesn't have a job executor so you can't see the next step's error, but you can still see that the code checkout step was missing the files in .git.

    Expected behavior in branch trigger

    Unexpected behavior in PR trigger

  • Robin Shen commented 6 months ago

    This is expected behavior. Pull request build fires against merged commit of source and target branch. So there is no refs being checked out. You may add an additional command to switch to a branch for instance git checkout -b dev to force refs being populated.

    Also I'd suggest to add a repository checkout step in downstream jobs instead of publishing repository as artifacts and use it later.

  • Robin Shen changed state to 'Closed' 6 months ago
    Previous Value Current Value
    Open
    Closed
  • doubleplusc commented 6 months ago

    Thanks for looking into it!

issue 1/1
Type
Bug
Priority
Normal
Assignee
Affected Versions
12.0.1
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-2497
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover