编程语言/Drone/ssh:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
第94行: 第94行:


{{Unknown|https://www.cnblogs.com/shiningrise/p/17877483.html}}
{{Unknown|https://www.cnblogs.com/shiningrise/p/17877483.html}}
<syntaxhighlight lang="yaml">
kind: pipeline
type: ssh
name: Ssh-Runner
server:
    host: xxxxx.org
    user: root
    password:
        from_secret: password
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>

2026年2月20日 (五) 15:47的版本

模板

kind: pipeline
type: docker
name: default

steps:

- name: commands
  image: appleboy/drone-ssh
  pull: always
  settings:
    host:
      from_secret: DRONE_HOST
    username: 
      from_secret: DRONE_NAME
    port: 
      from_secret: DRONE_PORT
    password:
      from_secret: DRONE_PSW
    command_timeout: 2m
    script:
      - nginx -s reload
      
trigger:
  branch:
    include:
      - master
  event:
    include:
      - push

示例

示例一

kind: pipeline
name: default

steps:
- name: clear
  image: appleboy/drone-ssh
  pull: true
  settings:
    host: wxy.kim
    port: 22
    username: root
    password: 服务器密码
    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 项目清理成功
- name: build
  image: docker:dind #选择docker:dind镜像
  volumes:
  - name: docker-sock
    path: /var/run/docker.sock #映射宿主机Docker
  commands:
  - docker -v
  - docker build -t osharp:v7 -f samples/web/Liuliu.Demo.WebApi/Dockerfile .
  #- docker login --username=shiningrise@aliyun.com --password=你的仓库密码 registry.cn-shanghai.aliyuncs.com
  #- docker tag osharp:v7 registry.cn-shanghai.aliyuncs.com/shiningrise/osharp:v7.0.1
  #- docker push registry.cn-shanghai.aliyuncs.com/shiningrise/osharp:v7.0.1
  - echo 项目构建成功

- name: deploy
  image: appleboy/drone-ssh
  pull: true
  settings:
    host: wxy.kim
    port: 22
    username: root
    password: 服务器密码
    command_timeout: 2m
    script: 
      - source /etc/profile
      #- docker run -e VIRTUAL_HOST=class.wxy.work -e VIRTUAL_PORT=80 -v /etc/timezone:/etc/timezone -v /etc/localtime:/etc/localtime -d  osharp:v7
      - cd /data/
      - docker-compose up -d
      - echo 项目部署成功

volumes:
  - name: docker-sock
    host:
      path: /var/run/docker.sock
trigger:
  branch:
    - docker

(来源摘自互联网示例,作者 https://www.cnblogs.com/shiningrise/p/17877483.html)


kind: pipeline
type: ssh
name: Ssh-Runner

server:
    host: xxxxx.org
    user: root
    password:
        from_secret: password

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