question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failing (?) feature "allow adding URLs to release assets"

See original GitHub issue

Current behavior

As of version 9.3.0 its possible to add urls to assets for linking to docker registry or other artifact storages.
Unfortunately I cant get this feature to work for me.
The URL to be used is given in my .releaserc.yml., but the pipeline fails (see at the bottom of this issue).

If I run the command manually (curl) (copied from the logs):

curl --request POST \
  --url https://gitlab.com/api/v4/projects/36721546/releases \
  --header 'Content-Type: application/json' \
  --header 'PRIVATE-TOKEN: <token>' \
  --data '{
	"tag_name": "v1.0.0",
	"description": "# 1.0.0 (2022-06-03)\n\n\n### Features\n\n* add url to release ([da40fc9](https://code.siemens.com/kilian.lienekampf.ext/semantic-release-test/commit/da40fc9e16a06dbbc3e27f0b90be9f13f51985bb))\n\n\n\n",
	"assets": {
		"links": [
			{
				"url": "https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md"
			}
		]
	}
}'

I get an error: "error": "assets[links][0][name] is missing" wich is understandable due to the fact that assets:links:name is required if a assets:links:url is given (see here(docs))

Expected behavior

Is there anything in my configuration not correct or is there a bug in this feature?
I tried adding the name variable in my .releaserc.yml but it would not go into the request:

- - "@semantic-release/gitlab"
    - assets:
        - url: https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md
          name: "some name"

Environment

plugins:
  - "@semantic-release/commit-analyzer"
  - "@semantic-release/release-notes-generator"
  - "@semantic-release/changelog"
  #- - "@semantic-release/exec"
  #  - prepareCmd: $CI_PROJECT_DIR/.m2/prepare.sh ${nextRelease.version}
  #    publishCmd: $CI_PROJECT_DIR/.m2/publish.sh
  - - "@semantic-release/git"
    - assets:
        - CHANGELOG.md
        - "**/*pom.xml"
  - - "@semantic-release/gitlab"
    - assets:
        - url: https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md
  # As discussed in this issue: https://github.com/semantic-release/semantic-release/issues/1603 there is no support for GitFlow.
  # If we would like to stick to kinda GitFlow (with prerelease/develop), we will have to use this community plugin or merge back by ourselves.
  - - "@saithodev/semantic-release-backmerge"
    - branches:
        - from: main
          to: prerelease
branches:
  - main
  - +([0-9])?(.{+([0-9]),x}).x
  - name: prerelease
    prerelease: rc
  • CI logs:
[7:53:34 AM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/gitlab"
2022-06-03T07:53:34.910Z semantic-release:gitlab repoId: 'kaerbr/semantic-release-test'
2022-06-03T07:53:34.910Z semantic-release:gitlab release name: 'v1.0.0'
2022-06-03T07:53:34.910Z semantic-release:gitlab release ref: '38320e22e6ea7ac172d1b85a37bc765b2948075d'
2022-06-03T07:53:34.910Z semantic-release:gitlab milestones: undefined
2022-06-03T07:53:34.911Z semantic-release:gitlab url assets: [ { url: 'https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md' } ]
2022-06-03T07:53:34.911Z semantic-release:gitlab globbed assets: []
2022-06-03T07:53:34.912Z semantic-release:gitlab all assets: [ { url: 'https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md' } ]
2022-06-03T07:53:34.913Z semantic-release:gitlab use link from release setting: https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md
2022-06-03T07:53:34.913Z semantic-release:gitlab Create a release for git tag 'v1.0.0' with commit '38320e22e6ea7ac172d1b85a37bc765b2948075d'
2022-06-03T07:53:34.914Z semantic-release:gitlab POST-ing the following JSON to https://gitlab.com/api/v4/projects/kaerbr%2Fsemantic-release-test/releases:
{
  "tag_name": "v1.0.0",
  "description": "# 1.0.0 (2022-06-03)\n\n\n### Features\n\n* add url to release ([da40fc9](https://gitlab.com/kaerbr/semantic-release-test/commit/da40fc9e16a06dbbc3e27f0b90be9f13f51985bb))\n\n\n\n",
  "assets": {
    "links": [
      {
        "url": "https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md"
      }
    ]
  }
}
[7:53:35 AM] [semantic-release] [@semantic-release/gitlab] › ✖  An error occurred while making a request to the GitLab release API:
HTTPError: Response code 400 (Bad Request)
    at Request.<anonymous> (/usr/local/lib/node_modules/@semantic-release/gitlab/node_modules/got/dist/source/as-promise/index.js:118:42)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 1654242814917,
    socket: 1654242814918,
    lookup: 1654242814918,
    connect: 1654242814928,
    secureConnect: 1654242814940,
    upload: 1654242814940,
    response: 1654242815095,
    end: 1654242815096,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 1,
      dns: 0,
      tcp: 10,
      tls: 12,
      request: 0,
      firstByte: 155,
      download: 1,
      total: 179
    }
  }
}
[7:53:35 AM] [semantic-release] › ✖  Failed step "publish" of plugin "@semantic-release/gitlab"
[7:53:35 AM] [semantic-release] › ✖  An error occurred while running semantic-release: HTTPError: Response code 400 (Bad Request)
    at Request.<anonymous> (/usr/local/lib/node_modules/@semantic-release/gitlab/node_modules/got/dist/source/as-promise/index.js:118:42)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 1654242814917,
    socket: 1654242814918,
    lookup: 1654242814918,
    connect: 1654242814928,
    secureConnect: 1654242814940,
    upload: 1654242814940,
    response: 1654242815095,
    end: 1654242815096,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 1,
      dns: 0,
      tcp: 10,
      tls: 12,
      request: 0,
      firstByte: 155,
      download: 1,
      total: 179
    }
  },
  pluginName: '@semantic-release/gitlab'
}

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
awcjackcommented, Jun 8, 2022

Edited!:

So I did some more research/debugging. The underlying problem is the following:

If I only specify url in my assets object:

{"url": "https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md"}

the call to the releases api of gitlab will only contain url. Thus there will be an error from the gitlab api ( name is also required for a link (see docs))

So the solution is to always add a label per link (this should fix it for you too @elvis-pereira (: ). like this:

{
  "url": "https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md",
  "label": "README.md"
}

I think the README.md should be improved to make it more clear. (:

But also thanks for this superb project! (:

Thanks for the investigation. 👍

1reaction
kaerbrcommented, Jun 7, 2022

Edited!:

So I did some more research/debugging. The underlying problem is the following:

If I only specify url in my assets object:

{"url": "https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md"}

the call to the releases api of gitlab will only contain url. Thus there will be an error from the gitlab api ( name is also required for a link (see docs))

So the solution is to always add a label per link (this should fix it for you too @elvis-pereira (: ). like this:

{
  "url": "https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md",
  "label": "README.md"
}

I think the README.md should be improved to make it more clear. (:

But also thanks for this superb project! (:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Permanent link to latest version of a release - Issues - GitLab
Retrieving a link to source or an asset should be possible using a predictable URL. Something like /releases/11.4/source. tar.
Read more >
Destination requirements - Advertising Policies Help
Ads that don't accurately reflect where the user is being directed · A domain or domain asset in the display URL that doesn't...
Read more >
URL.createObjectURL() - Web APIs | MDN
To release an object URL, call revokeObjectURL() . Note: This feature is available in Web Workers. Note: This feature is not available in ......
Read more >
Error Messages | Maps JavaScript API - Google Developers
The current URL loading the Maps JavaScript API has not been added to the list of allowed referrers. Please check the referrer settings...
Read more >
AEM 6.4 Service Pack Release Notes | Adobe Experience Manager
Collections are removed from the view on applying any filter in AEM Assets accessed from Adobe Asset Link (CQ-4280534). Batch size and workflow...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found