我有一个单独的项目,其中只有 gitlab-ci.yml。
管道项目:
我有多个项目访问此管道。但我在一些项目中有一个 .sh 脚本,我需要从主管道项目运行它。我不确定如何访问管道项目中的脚本。
文件 role.sh 位于我应该从管道项目访问的另一个项目中。
.deploy_template: &deploy
image: docker.artifactory.com/projects/finance:latest
dependencies:
- build
script:
- cp scripts/role.sh rc.sh
- chmod +x rc.sh
- ./rc.sh
您能否指导我如何在另一个项目中运行一个项目中的脚本?
最佳答案
鉴于您有权访问包含脚本的项目,您可以克隆该项目,然后运行脚本:
.deploy_template: &deploy
image: docker.artifactory.com/projects/finance:latest
dependencies:
- build
script:
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${PROJECT_PATH}.git
- cd ${directory_locates_script}
- chmod +x rc.sh
- ./rc.sh
关于gitlab - 从 Gitlab 中的其他项目运行脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72118708/