Uploaded image for project: 'IT: Release Engineering'
  1. IT: Release Engineering
  2. RELENG-2685

Global-jjb release-job.sh fails to detect files on non-ff git merge part 2

Issue XMLXMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • Q4 2019 Tech Debt
    • None
    • Global JJB
    • None
    • ORAN

      The global-jjb shell script release-job.sh works on git fast-forward merges and simple merges, but fails on merge of a change with just a single release file if the commit has multiple parents. Forgive me for not describing it better, I found it very confusing! Please see this Acumos job failure for the exact repository commit & merge situation:

      https://jenkins.acumos.org/job/on-boarding-app-release-merge/15/console

      The commit ID is 2a3d5e7a3ea985f54befa8d99359b92a9f2bc597

      Anyhow, the line that breaks is in the script's set_variables_common function:

      release_files=$(git diff-tree --no-commit-id -m -r "$GIT_COMMIT" --name-only -- "releases/" ".releases"
      

      I think that line just needs to be extended with another tree-ish reference per documentation from git-diff-tree:

      release_files=$(git diff-tree --no-commit-id -m -r "$GIT_COMMIT"  "$GIT_COMMIT^1"  --name-only -- "releases/" ".releases"
      

      I tested in a fast-forward merge and it worked. When I tested that in the context of the job shown above it also works:

      (venv-py37) clott@mbp-cl778h:~/git/acumos/on-boarding% export GIT_COMMIT=2a3d5e7a3ea985f54befa8d99359b92a9f2bc597
      # next the existing command, you'll see it emits two file names                           
      (venv-py37) clott@mbp-cl778h:~/git/acumos/on-boarding% git diff-tree -m -r --no-commit-id $GIT_COMMIT  --name-only -- releases/ .releases/
      releases/release-onboarding-base-r-1_0_0.yaml
      releases/release-4.1.0-maven-docker.yaml
      # next my proposed command, it emits just one file name
      (venv-py37) clott@mbp-cl778h:~/git/acumos/on-boarding% git diff-tree -m -r --no-commit-id $GIT_COMMIT $GIT_COMMIT^1 --name-only -- releases/ .releases/
      releases/release-onboarding-base-r-1_0_0.yaml
      

      Please consider, thanks.

              agardner Aric Gardner
              cl778h Chris Lott
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: