Skip to content

call from Powershell with --assets-link does not work as documented

Summary

Using the --assets-link command through the gitlab yml interface or directly using the command line interface as described in the documentation fails with a JSON error.

Steps to reproduce

Call release-cli from powershell as described in the example from the documentation: !88 (84b5d148) (tested with Gitlab 14.0 and Powershell 5.1.17763.1971) Details are also described in this Forums post: https://forum.gitlab.com/t/ci-release-tag-building-wrong-eleas-cli-format-for-powershell/55320

Example Project

  • (unfortunately lies in a private repository)

What is the current bug behavior?

release-cli fails with failed to parse assets: invalid JSON

What is the expected correct behavior?

Release is generated with asset link

Relevant logs and/or screenshots

$ release-cli create --name "Release $CI_COMMIT_TAG" --description "ReleaseDetails.md" --tag-name "$CI_COMMIT_TAG" --ref "$CI_COMMIT_SHA" --assets-link "{\"name\":\"Release binaries\",\"url\":\"http://git.com\",\"link_type\":\"package\"}"
time="2021-07-05T13:56:56+02:00" level=info msg="Creating Release..." cli=release-cli command=create name="Release 00.07" project-id=102 ref=18683a0eccbe2f078e55e8c90c2755f3ed632ad7 server-url="..." tag-name=00.07 version=0.6.0
time="2021-07-05T13:56:56+02:00" level=fatal msg="new CreateReleaseRequest: failed to parse assets: invalid JSON: \"{\\\\\"" cli=release-cli version=0.6.0

Output of checks

Possible fixes

Workaround: Using the old --assets-links-name and --assets-links-url interface Which would be made impossible by finishing #49 (closed)

Proposal

Support parsing a JSON string to a string compatible with PowerShell' syntax in https://gitlab.com/gitlab-org/gitlab/-/blob/9902fed15fc0fbe0c71201c10399402277feb9f0/lib/gitlab/ci/build/releaser.rb#L41

  1. GitLab would need to know if the request is coming from a Windows/PowerShell runner
  2. Escape the JSON strings correctly
Edited by Oliver Müller