gpt4 book ai didi

gitlab-ci - gitlab CI/CD 如何执行如图所示的多行命令

转载 作者:行者123 更新时间:2023-12-01 23:12:08 24 4
gpt4 key购买 nike

我想在 gitlabl CI/CD 中执行如下命令

ssh $DEPLOY_USER@$DEPLOY_HOST <<'ENDSSH'                                                                    
set -x -o verbose;
execute some command here
set +x
ENDSSH

如何在脚本中添加这样的命令

deploy-to-stage:
stage: deploy
before_script:
- "which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )"
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
script:
- *** HERE I WANT TO RUN THAT COMMAND ***

我该怎么做

最佳答案

你可以这样做:

script:
- |
ssh $DEPLOY_USER@$DEPLOY_HOST <<'ENDSSH'
set -x -o verbose;
execute some command here
set +x
ENDSSH

关于gitlab-ci - gitlab CI/CD 如何执行如图所示的多行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69734940/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com