I have developed a tool which allows users to run predefined pipeline in Gitlab-CI, and I run the pipeline via API. Inside the pipeline, there is some logic going on, mainly Ansible related.
At some point, there is a commit. Lately, I have face some problems because the commit started to fail in some cases, because a git rebase was needed. I improved the logic, wrote a script that I call inside the pipeline script.
Now, 90% of my pipelines works, and the others 10% fail, because the script is missing. All the pipelines are triggered at the same point in time (a few milliseconds delay), so it should start on the same commit, using the same repository state.
Example : Runner that succeeded
Running with gitlab-runner 15.11.0 (436955cb)
on gitlab-runner-node-201 GKC5Dcxe, system ID: s_7bbf7487f540
[...]
section_start:1689279186:get_sources
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/ansible-central/ansible-command-center/.git/
Checking out a1387351 as detached HEAD (ref is disable-rebase)...
[...]
$ git log -1 --oneline
a138735 🤔 Ajout debug
[...]
$ git config --global user.name "${author_name}"
$ git config --global user.email "${author_email}"
$ git config pull.rebase true
$ git checkout ${CI_COMMIT_REF_NAME}
Previous HEAD position was a138735 🤔 Ajout debug
Switched to branch 'disable-rebase'
Your branch is behind 'origin/disable-rebase' by 2 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
$ git branch -u origin/${CI_COMMIT_REF_NAME}
branch 'disable-rebase' set up to track 'origin/disable-rebase'.
Example : Runner that failed
Running with gitlab-runner 15.11.0 (436955cb)
on gitlab-runner-node-203 xsX26gLC, system ID: s_7bbf7487f540
[...]
section_start:1689279121:get_sources
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/ansible-central/ansible-command-center/.git/
Checking out a1387351 as detached HEAD (ref is disable-rebase)...
[...]
$ git log -1 --oneline
a138735 🤔 Ajout debug
[...]
$ git config --global user.name "${author_name}"
$ git config --global user.email "${author_email}"
$ git config pull.rebase true
$ git checkout ${CI_COMMIT_REF_NAME}
Previous HEAD position was a138735 🤔 Ajout debug
Switched to branch 'disable-rebase'
Your branch and 'origin/disable-rebase' have diverged,
and have 1 and 50 different commits each, respectively.
[...]
/bin/bash: line 235: ./juno/utils/commit.sh: No such file or directory
So I don’t understand :
- The two runners were triggered on the same time (
1689279186
and1689279121
) - The git commit was the same :
a138735
- When I run the command
git checkout ${CI_COMMIT_REF_NAME}
I get two different results :
Previous HEAD position was a138735 🤔 Ajout debug
Switched to branch 'disable-rebase'
Your branch is behind 'origin/disable-rebase' by 2 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Previous HEAD position was a138735 🤔 Ajout debug
Switched to branch 'disable-rebase'
Your branch and 'origin/disable-rebase' have diverged,
and have 1 and 50 different commits each, respectively.
How can the two commands, from the same state of the repo gives two different outputs ?