semantic-release / gitlab

:fox_face: semantic-release plugin to publish a GitLab release
MIT License
283 stars 78 forks source link

Question: Use (environment) variable for URL (and label) #407

Closed kaerbr closed 2 years ago

kaerbr commented 2 years ago

I would like to be able to set url( and label dynamically).

Lets say I've set an environment URL in my .gitlab-ci.yml (will be set dynamically in the "real world") :

image: node:lts-alpine
stages:
  - release
semantic-release:
  stage: release
  script:
    - export ARTIFACT_URL="https://my.url/to/my/artifact"
    - apk update && apk upgrade
    - apk add --no-cache git
    - npm install -g semantic-release@19 @semantic-release/changelog@6 @semantic-release/exec@6 @semantic-release/git@10 @semantic-release/gitlab@9
    - semantic-release --debug

If I try to pass this variable into the gitlab plugin, the variable won't resolve. See .releaserc.yml:

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} $CI_PROJECT_DIR
      publishCmd: $CI_PROJECT_DIR/.m2/publish.sh
  - - "@semantic-release/git"
    - assets:
        - CHANGELOG.md
        - "**/*pom.xml"
  - - "@semantic-release/gitlab"
    - assets:
        - url: $ARTIFACT_URL
          label: "my-artifact"
          type: other
branches:
  - main

This will result in the following JSON payload that will be send to the gitlab releases API:

"assets": {
    "links": [
      {
        "name": "URL",
        "url": "$ARTIFACT_URL",
        "link_type": "other"
      }
    ]
  }

and will result in an error cause gitlab checks the url field to really be a URL.

So my question: Is there any supported way of giving custom variable inputs to the gitlab plugin? (:

jagiella commented 2 years ago

I guess, that my question points into a similar direction:

406

fgreinacher commented 2 years ago

Yes, I think we can close this in favor of https://github.com/semantic-release/gitlab/issues/406.

kaerbr commented 2 years ago

Closing in favour of #406