Curl Gitlab ci赢得';t在ssh命令中替换我的变量
在我的gitlab-ci.yml中,我有一个命令,可以通过一个curl post在gitlab中创建一个发行版Curl Gitlab ci赢得';t在ssh命令中替换我的变量,curl,gitlab-ci,Curl,Gitlab Ci,在我的gitlab-ci.yml中,我有一个命令,可以通过一个curl post在gitlab中创建一个发行版 # create release - >- curl --request POST -H 'PRIVATE-TOKEN: ${GITLABAPI_TOKEN}' -H 'Content-Type: application/json' --data "{\"description\": \"`git log $(git describe --tags --
# create release
- >-
curl --request POST -H 'PRIVATE-TOKEN: ${GITLABAPI_TOKEN}' -H 'Content-Type: application/json' --data "{\"description\": \"`git log $(git describe --tags --abbrev=0)..HEAD --oneline`\"}" https://gitlab.unc.nc/api/v4/projects/${APP_GITLAB_NUMBER}/repository/tags/${CI_COMMIT_TAG}/release
此请求获得“401 unauthorized”,因为我怀疑-H“PRIVATE-TOKEN:${GITLABAPI_TOKEN}”没有被变量值替换。
与:${GITLABAPI_TOKEN}$GITLABAPI_TOKEN“${GITLABAPI_TOKEN}”相同
如果我这样显示该值,则该值为ok:
ssh root@devsb01 "echo $GITLABAPI_TOKEN"
如果我直接使用密码值启动post,它会工作:
- >-
curl --request POST -H 'PRIVATE-TOKEN: xkwMyRealPwdùwsx' -H 'Content-Type: application/json' --data "{\"description\": \"`git log $(git describe --tags --abbrev=0)..HEAD --oneline`\"}" https://gitlab.unc.nc/api/v4/projects/${APP_GITLAB_NUMBER}/repository/tags/${CI_COMMIT_TAG}/release
我想我需要添加一些东西到命令中,这样它就可以替换它了。。。但是我不知道怎么
注意,url变量:${APP\u GITLAB\u NUMBER}和${CI\u COMMIT\u TAG}在单引号中被正确替换,shell不展开任何内容。请将私人代币放入双引号:
curl --request POST -H "PRIVATE-TOKEN: ${GITLABAPI_TOKEN}" -H 'Content-Type: application/json' --data "{\"description\": \"`git log $(git describe --tags --abbrev=0)..HEAD --oneline`\"}" https://gitlab.unc.nc/api/v4/projects/${APP_GITLAB_NUMBER}/repository/tags/${CI_COMMIT_TAG}/release