编程语言/Drone/ssh:修订间差异
来自康健生活
无编辑摘要 |
|||
| 第1行: | 第1行: | ||
== 引言 == | |||
[https://github.com/appleboy/drone-ssh appleboy/drone-ssh]: Drone plugin for executing remote ssh commands. | |||
== 模板 == | == 模板 == | ||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
- name: clear | |||
image: appleboy/drone-ssh | |||
pull: true | |||
settings: | |||
host: 192.168.1.1 | |||
port: 22 | |||
username: root | |||
password: 12345678 | |||
command_timeout: 2m | |||
script: | |||
- source /etc/profile | |||
- ls -la | |||
- docker info | |||
- docker stop `docker ps -a| grep osharp | awk '{print $1}'` | |||
- docker rm $(docker ps -a | grep Exited | awk '{print $1}') | |||
- docker rm $(docker ps -a | grep Created | awk '{print $1}') | |||
#- docker rmi $(docker images | grep "none" | awk '{print $3}') | |||
- echo 项目清理成功 | |||
</syntaxhighlight> | |||
变量 | |||
<syntaxhighlight lang="yaml"> | |||
- name: commands | - name: commands | ||
image: appleboy/drone-ssh | image: appleboy/drone-ssh | ||
| 第22行: | 第42行: | ||
script: | script: | ||
- nginx -s reload | - nginx -s reload | ||
</syntaxhighlight> | |||
== 示例 == | == 示例 == | ||
=== 示例一 === | === 示例一 === | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
- name: build | - name: build | ||
image: docker:dind #选择docker:dind镜像 | image: docker:dind #选择docker:dind镜像 | ||
| 第68行: | 第59行: | ||
#- docker push registry.cn-shanghai.aliyuncs.com/shiningrise/osharp:v7.0.1 | #- docker push registry.cn-shanghai.aliyuncs.com/shiningrise/osharp:v7.0.1 | ||
- echo 项目构建成功 | - echo 项目构建成功 | ||
- name: deploy | - name: deploy | ||
image: appleboy/drone-ssh | image: appleboy/drone-ssh | ||
| 第99行: | 第89行: | ||
kind: pipeline | kind: pipeline | ||
type: ssh | type: ssh | ||
name: | name: ssh-runner | ||
server: | server: | ||
host: 192.168.1.1 | |||
user: root | |||
password: | |||
from_secret: password | |||
steps: | steps: | ||
- name: list | |||
commands: | |||
- ls /var | |||
- name: npm | |||
environment: | |||
PATH: "$$PATH:/opt/node-v14.3.0-linux-x64/bin/" | |||
commands: | |||
- pwd | |||
- node --version | |||
- npm version | |||
- npm install | |||
</syntaxhighlight> | </syntaxhighlight> | ||