Open juannn91 opened 2 years ago
Hi all,
I spend most of my last two days looking into this issue and I found a (temporary) solution for this. The issue that you describe is caused by the commit author email (semantic-release-bot@martynus.net by default). Depending on the settings, GitLab may refuse commits whose author email does not correspond to a project member (the GitLab bot does NOT have email semantic-release-bot@martynus.net). If this setting is enabled I experience the same behaviour as you.
The setting can be disabled in "Repository Settings" -> "Push rules" -> "Select push rules" -> uncheck "Check whether the commit author is a GitLab user". If I do that, everything works like a charm!
To improve this workflow I'd like to set GIT_COMMITTER_EMAIL
to the email of my bot. It appears that the bots have a default email address (link), but in our self-hosted GitLab instance the bots do not seem to have an email address so I'll have to dive deeper.
Please let me know if this solves your issue, or perhaps whether you found another solution. Thoughts that relate to my 'next step' are also welcome.
It appears that our bots DO have emails, but the API call was limited. The following yields an email address: curl -s --request GET --header "PRIVATE-TOKEN:<GL_TOKEN>" "${CI_API_V4_URL}/user" | jq '.email'
So perhaps if the container has jq
and curl
installed one can start the script with GIT_COMMITTER_EMAIL=$(curl -s --request GET --header "PRIVATE-TOKEN:$GL_TOKEN" "${CI_API_V4_URL}/user" | jq '.email')
and everything would work without changing the settings. I'll get back to this in a few weeks.
Update 22-9-2922: remove concrete API URL and use far better suggestion by @mato-a below.
Yep, adding the following snippet to the script solves my problem without need for repo configuration changes:
script:
- export GIT_COMMITTER_EMAIL=$(curl -s --request GET --header "PRIVATE-TOKEN:$GL_TOKEN" "${CI_API_V4_URL}/user" | jq '.email')
- export GIT_AUTHOR_EMAIL=$GIT_COMMITTER_EMAIL
- semantic-release ...
Update 22-9-2922: remove concrete API URL and use far better suggestion by @mato-a below.
Hello there,
I've had exactly the same error as @juannn91.
I have had all working correct until 18 of Agust ...
Error appeared some time after 18. August when I think the option Check whether the commit author is a GitLab user
mentioned by @b-kamphorst was introduced with new GitLab release and set to true
by default.
The setting can be disabled in "Repository Settings" -> "Push rules" -> "Select push rules" -> uncheck "Check whether the commit author is a GitLab user". If I do that, everything works like a charm!
I can confirm that the solution is either to set Check whether the commit author is a GitLab user
to false
or to include something like this before triggering semantic-release
. I've chosen the latter as it is probably more secure.
before_script:
- export GIT_AUTHOR_EMAIL="$(curl -s -X GET -H "PRIVATE-TOKEN:$GITLAB_TOKEN" "${CI_API_V4_URL}/user" | jq -r '.email')"
- export GIT_COMMITTER_EMAIL="${GIT_AUTHOR_EMAIL}"
script:
- npm run release
Thank you both! 🚀👍
Hello there,
I've had exactly the same error as @juannn91.
I have had all working correct until 18 of Agust ...
Error appeared some time after 18. August when I think the option
Check whether the commit author is a GitLab user
mentioned by @b-kamphorst was introduced with new GitLab release and set totrue
by default.The setting can be disabled in "Repository Settings" -> "Push rules" -> "Select push rules" -> uncheck "Check whether the commit author is a GitLab user". If I do that, everything works like a charm!
I can confirm that the solution is either to set
Check whether the commit author is a GitLab user
tofalse
or to include something like this before triggeringsemantic-release
. I've chosen the latter as it is probably more secure.before_script: - export GIT_AUTHOR_EMAIL="$(curl -s -X GET -H "PRIVATE-TOKEN:$GITLAB_TOKEN" "${CI_API_V4_URL}/user" | jq -r '.email')" - export GIT_COMMITTER_EMAIL="${GIT_AUTHOR_EMAIL}" script: - npm run release
Thank you both! 🚀👍
Works great for me. Thanks, @mato-a !
I have had all working correct until 18 of Agust when I start to see the following message:
I have tried to:
No success until today.
Maybe some idea of where can I look??
my package version:
My CI:
My logs:
Thanks!!