问题描述
我们使用 GitLab CI/CD 实践自动化,有时我们需要在远程主机执行部署命令。
该笔记将记录:在 GitLab CI/CD 中,如何在远程主机中执行命令。
解决方案
使用 GitLab Runner / SSH Executor 功能。
第一步、注册 SSH Execurtor 执行器
# gitlab-runner register Runtime platform arch=amd64 os=linux pid=42 revision=ac8e767a version=12.6.0 Running in system-mode. Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/): http://gitlab.exmaple.com ------------------------------------------------------ <输入 GitLab 地址> Please enter the gitlab-ci token for this runner: xxxxxxxxxx --------------------------------------------------------------------- <在 Admin Area / Overview Runners 中查看> Please enter the gitlab-ci description for this runner: [eec8077625c3]: ssh executor --------------------------------------------------- <添加描述信息> Please enter the gitlab-ci tags for this runner (comma separated):

本文介绍如何在GitLab CI/CD环境中通过SSH Executor功能实现在远程主机上执行部署命令。主要包括注册SSH Executor执行器的具体步骤及在.gitlab-ci.yml文件中配置执行器的方法。
最低0.47元/天 解锁文章
5959

被折叠的 条评论
为什么被折叠?



