「GitLab CI/CD」- 在远程主机中执行命令 @20210318

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

问题描述

我们使用 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):
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值