.zip 上的 gitlab 上传到通用失败

gitlab upload to generic fails on .zip

我有一个上传 gitlab-ci.yaml 例程,它是从 gist 那里得到的。但是出现错误。任何人都知道如何将 .zip 上传到通用文件吗?我需要更改令牌类型吗?我在 gitlab.com 和他们提供的 运行ners

# Refer to: https://gitlab.com/gitlab-org/release-cli/-/tree/master/docs/examples/release-assets-as-generic-package/
upload:
  stage: upload
  image: curlimages/curl:latest
  script:
    - ls -la
    - |
      PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print  }' | sed 's/[",]//g')
      PACKAGE_REGISTRY_URL="https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${PACKAGE_VERSION}"
      curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file ${CI_PROJECT_NAME}.zip ${PACKAGE_REGISTRY_URL}/${CI_PROJECT_NAME}.zip
      echo 'Package uploaded!'

这里是错误的运行

$ PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print  }' | sed 's/[",]//g') # collapsed multi-line command
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1861k  100    27  100 1861k     44  3100k -{"error":"file is missing"}-:--:-- --:--:-- --:--:-- 3102k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (7) Failed to connect to 0.0.0.0 port 80 after 1 ms: Connection refused
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: exit code 7

原来字符串中有一个 space.. 打破了 URL

所以我添加了

PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print  }' | sed 's/[",]//g' | xargs )