GitlabCI:如何将变量从gitlab ci/cd传递到ssh并在远程卷曲命令中使用?

问题描述 投票:0回答:1

script: - start_build_message="The project build has started! I will notify you when it's completed. Author $GITLAB_USER_NAME." - echo "$start_build_message" - ssh -o "StrictHostKeyChecking=no" "$SSH_USERNAME"@"$SSH_HOST" "curl -s -X POST 'https://api.telegram.org/$TELEGRAM_BOT_TOKEN/sendMessage' \ -d chat_id=$TELEGRAM_CHAT_ID \ --data-urlencode text=\"\${start_build_message}\""

您的问题可能是由于SSH命令中的可变扩展而引起的。
script:
  - start_build_message="The project build has started! I will notify you when it's completed. Author $GITLAB_USER_NAME."
  - echo "$start_build_message"
  - ssh -o "StrictHostKeyChecking=no" "$SSH_USERNAME@$SSH_HOST" \
    "start_build_message=\"${start_build_message}\" && \
    curl -s -X POST 'https://api.telegram.org/$TELEGRAM_BOT_TOKEN/sendMessage' \
    -d chat_id=$TELEGRAM_CHAT_ID --data-urlencode text=\"\${start_build_message}\""
curl ssh gitlab-ci
1个回答
0
投票
script: - start_build_message="The project build has started! I will notify you when it's completed. Author $GITLAB_USER_NAME." - echo "$start_build_message" - ssh -o "StrictHostKeyChecking=no" "$SSH_USERNAME@$SSH_HOST" \ "curl -s -X POST 'https://api.telegram.org/$TELEGRAM_BOT_TOKEN/sendMessage' \ -d chat_id=$TELEGRAM_CHAT_ID --data-urlencode text=\"$(echo $start_build_message)\""


最新问题
© www.soinside.com 2019 - 2025. All rights reserved.