Open rmelotte opened 2 years ago
Hi! Thanks for reporting this.
The problem is that CI_COMMIT_BRANCH is unset in pipelines for merge requests.
I think this is the same issue as #104. I just pushed a branch I worked on a while ago with a potential fix for this: gitlab-detacted-pipelines-fix
. I can't test it because I don't have access to this feature (from what I remember). If you could test it, it'd be great!
Just tested this branch, see https://gitlab.com/xen-project/xen-guest-agent/-/merge_requests/30
There is a command error that does not get caught, and the DCO is reported as good without even being checked.
I'll fix this so that the error is properly reported. As for why the error happens, can you try doing a git fetch
in CI before running dco-check
? I'm guessing it doesn't know anything about the main
branch (target) since it's a "detached" pipeline.
See https://gitlab.com/xen-project/xen-guest-agent/-/jobs/5796509345
As you said it would help to know about main
branch, but then it would be origin/main
.
If I create the local main
branch OTOH it starts to work:
https://gitlab.com/xen-project/xen-guest-agent/-/jobs/5796533504
When the pipelines for merge requests feature is used,
dco-check
fails with the following error:I reproduced it in a test repository here: https://gitlab.com/raphael.melotte/dco-check-test/-/jobs/1655135885 . And it's also possible to reproduce it manually outside of Gitlab:
The problem is that CI_COMMIT_BRANCH is unset in pipelines for merge requests. From https://docs.gitlab.com/ee/ci/variables/predefined_variables.html:
A possible workaround is to manually set the variable. For example:
With that,
dco-check
fails, but without giving any reason. See this job, or run the following in a local repository:This time the problem is with the
CI_MERGE_REQUEST_TARGET_BRANCH_SHA
variable: it's set, but empty in merge requests pipelines:As a workaround for the current version, one can set it manually. For example:
or:
While this works, it has the same problem as in https://github.com/christophebedard/dco-check/issues/113 (i.e.
git merge-base --fork-point
can fail in some scenarios).