I'm trying to generate files in parallel steps and commit them to a new (shared) branch.
image: atlassian/default-image:4.20230906
pipelines:
custom:
test-parallel-creation-of-artifacts:
- step:
name: Create Shared Files
runs-on:
- self.hosted
- linux
artifacts:
- generated-artifacts/**
script:
- mkdir generated-artifacts
- echo "shared" > generated-artifacts/shared-1.txt
- echo "shared" > generated-artifacts/shared-2.txt
- export NEW_BRANCH=${BITBUCKET_BRANCH}_test-artifacts_${BITBUCKET_BUILD_NUMBER}
- git checkout -b ${NEW_BRANCH}
- git add generated-artifacts/*
- git status
- git commit -m "Create shared files"
- git push origin ${NEW_BRANCH}
- parallel:
steps:
- step:
name: Create file 1 and modify shared file 1
runs-on:
- self.hosted
- linux
artifacts:
- generated-artifacts/**
script:
- touch generated-artifacts/1.txt
- echo "parallel-1" >> generated-artifacts/shared-1.txt
- export NEW_BRANCH=${BITBUCKET_BRANCH}_test-artifacts_${BITBUCKET_BUILD_NUMBER}
- git fetch origin
- git branch -a
- git checkout -b ${NEW_BRANCH}
- git pull
- git status
- git show HEAD -q
- git add generated-artifacts/*
- git status
- git commit -m "Update (part 1)"
- git push origin ${NEW_BRANCH}
- step:
name: Create file 2 and modify shared file 2
runs-on:
- self.hosted
- linux
artifacts:
- generated-artifacts/**
script:
- touch generated-artifacts/2.txt
- echo "parallel-2" >> generated-artifacts/shared-2.txt
- export NEW_BRANCH=${BITBUCKET_BRANCH}_test-artifacts_${BITBUCKET_BUILD_NUMBER}
- git fetch origin
- git branch -a
- git checkout -b ${NEW_BRANCH}
- git pull
- git status
- git show HEAD -q
- git add generated-artifacts/*
- git status
- git commit -m "Update (part 2)"
- git push origin ${NEW_BRANCH}As you can see, I create the branch in the first step with a new commit. However, if I checkout the branch and pull in one of the parallel steps, it claims
Already up to date.
but HEAD is still the commit before the commit added by "Create Shared Files". If I look at the branches in Bitbucket (https://bitbucket.org/org/proj/branches/), it shows the branch with the commit "Create shared files". Why can't the parallel steps pull this commit?