gitlab
gitlab copied to clipboard
Error in request to create release
Hello everyone
I'm receiving an error when I run the semantic release in last step. The code can create the tag, but after this, there is a request to /release
that I'm receiving a 400 error code
[3:27:32 PM] [semantic-release] [@semantic-release/changelog] › ℹ Create /tmp/build/group/project-name/CHANGELOG.md
[3:27:32 PM] [semantic-release] › ✔ Completed step "prepare" of plugin "@semantic-release/changelog"
[3:27:33 PM] [semantic-release] › ✔ Created tag v1.3.1
[3:27:33 PM] [semantic-release] › ℹ Start step "publish" of plugin "@semantic-release/gitlab"
[3:27:33 PM] [semantic-release] › ✖ Failed step "publish" of plugin "@semantic-release/gitlab"
[3:27:33 PM] [semantic-release] › ✖ An error occurred while running semantic-release: HTTPError: Response code 400 (Bad Request)
at EventEmitter.<anonymous> (/usr/local/lib/node_modules/@semantic-release/gitlab/node_modules/got/dist/source/as-promise.js:118:31)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
pluginName: '@semantic-release/gitlab'
}
HTTPError: Response code 400 (Bad Request)
at EventEmitter.<anonymous> (/usr/local/lib/node_modules/@semantic-release/gitlab/node_modules/got/dist/source/as-promise.js:118:31)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
pluginName: '@semantic-release/gitlab'
}
I start to investigate the problem in code and I put a debug with error message in API:
2020-12-17T16:59:53.675Z semantic-release:gitlab error in request: Response code 400 (Bad Request)
2020-12-17T16:59:53.675Z semantic-release:gitlab {"error":"name is missing"}
Is required a field called name
in json data send with GOT.
https://github.com/semantic-release/gitlab/blob/f8957c30a29f851e9400a6a3bbe169d9b9c7cfbb/lib/publish.js#L73-L87
There is no field called name
in this file
I changed and add a name with any value and I received a 201 code.
Is this a bug, different version or I made something wrong?
Thanks for this
Thanks for this detailed report @tacnoman!
It's interesting, because the name
field is optional in GitLab's Release API: https://docs.gitlab.com/ee/api/releases/#create-a-release 🤔
Is it possible that one of the asset's names is coming through as null
/undefined
? The name
property is required on each asset link object.
In the code you linked to, I see the asset name is being populated like this:
name: label || alt,
Perhaps these are both falsy for some reason 🤔
Assuming you are including assets with your release, could you try adding a label
in your configuration file as described here?
Even if this does work, this sounds like a bug to me.
@tacnoman I put together a quick branch in my fork that logs the JSON being sent to the GitLab API. (Here's the commit.)
If you replace your this line in your package.json
:
"@semantic-release/gitlab": "^6.0.8"
with this:
"@semantic-release/gitlab": "nfriend/gitlab#debugging-issues-192"
and rerun npm install
and your deploy, you should see the JSON printed in your logs. If this works for you, would you mind posting the JSON here?
(Disclaimer: I haven't tested this, so it's possible it might not work 😅)
I got the same problem. And I try to set name in publish.js and it works at localhost.
I got the same problem. code 400
I tried to add the attribute "name" to the body, and the result was successful. I hope to optimize it as soon as possible, I think it may be a bug, thank you
Meet the same issue.
And the Gitlab version is: 13.6.1
It should be similar to my question, and I have submitted a PR and it is waiting for review #239
Any update?
I solved creating a new file with name and in pipeline after install I replace the file
Release:
......
script:
- cp ./publish.js /usr/local/lib/node_modules/@semantic-release/gitlab/lib/publish.js
- DEBUG=semantic-release:gitlab npx semantic-release
I copied the publish.js to my project folder and added a parameter name, like this:
//...... line 75
json: {
/* eslint-disable camelcase */
tag_name: gitTag,
name: `Bump tag: ${gitTag}`, // Added this line
description: notes && notes.trim() ? notes : gitTag,
assets: {
// ......
@renatocassino @merlosy I am successfully using this plugin with our self-hosted GitLab instance. Can you share more details of your setup to help understand what could be the reason for your issues?
Possibly interesting information:
- Your semantic-release config
- Version and flavor of your GitLab instance
- Your build/release pipeline