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

来自康健生活
Kangkk​(留言 | 贡献)
创建页面,内容为“== 标题文本 == <syntaxhighlight lang="yaml"> kind: pipeline name: example-service trigger: branch: - master steps: - name: npm-auth image: robertstettner/drone-npm-auth settings: username: username password: password email: username@iftech.io registry: https://npm.yourcompany.com scope: '@jike' - name: install image: node:10 commands: - npm ci - name: lint image: node:10 commands:…”
 
Kangkk​(留言 | 贡献)
第66行: 第66行:
     ports:
     ports:
       - 27017</syntaxhighlight>
       - 27017</syntaxhighlight>
<syntaxhighlight lang="yaml">
kind: pipeline # 定义一个管道
type: docker # 当前管道的类型
name: test # 当前管道的名称
volumes: # 声明数据卷(此为服务器中的实际目录)
  - name: node_modules # 数据卷名称
    host: # Host Volume
      path: /volumes/drone/volumes/blog/node_modules # 宿主机目录    #绝对路径
  - name: deploy_path
    host:
      path: /workspace/blog
clone:
  disable: false # 启用代码拉取
steps: # 定义管道的执行步骤
  - name: deploy # 步骤名称
    image: node:16.13.2 # 当前步骤使用的镜像
    depends_on: [clone] # 依赖的步骤
    volumes: # 挂载数据卷(此为容器内的目录)
      - name: node_modules # 数据卷名称
        path: /drone/src/node_modules # 容器内目录 绝对路径
      - name: deploy_path
        path: /drone/src/html
    commands: # 当前步骤执行的命令
      - pwd # 查看当前目录
      - npm config set registry https://registry.npm.taobao.org # 切换淘宝镜像
      - npm install # 安装node_modules包
      - npm run build # 执行编译
      # - rm -fr ./blog
      - ls /drone/src
      - cp -r ./public/* ./html</syntaxhighlight>

2026年2月15日 (日) 10:58的版本

标题文本

kind: pipeline
name: example-service

trigger:
  branch:
    - master

steps:
  - name: npm-auth
    image: robertstettner/drone-npm-auth
    settings:
      username: username
      password: password
      email: username@iftech.io
      registry: https://npm.yourcompany.com
      scope: '@jike'
  - name: install
    image: node:10
    commands:
      - npm ci
  - name: lint
    image: node:10
    commands:
      - npm run lint
  - name: compile
    image: node:10
    commands:
      - npm run compile
  - name: test
    image: node:10
    commands:
      - npm t
  - name: ecr-build-push
    image: plugins/ecr
    settings:
      repo: example.ecr.region.amazonaws.com/example-service
      registry: example.ecr.region.amazonaws.com
      region: region
      create_repository: true
      tags:
        - ${DRONE_SOURCE_BRANCH//\//-}-${DRONE_COMMIT:0:7}
  - name: notify
    image: plugins/webhook
    settings:
      urls: http://jkdpy-dashboard-svc.infra:8000/api/images/
      content_type: application/x-www-form-urlencoded
      template: | 
      image_name=example.ecr.region.amazonaws.com/example-service:${DRONE_COMMIT:0:7}&\
      branch_name=${DRONE_SOURCE_BRANCH}&\
      service_name=example-service&\
      commit_message=${DRONE_COMMIT_MESSAGE}

services:
  - name: kafka
    image: spotify/kafka
    ports:
      - 9092
  - name: redis
    image: redis
    ports:
      - 6379
  - name: mongo
    image: mongo
    ports:
      - 27017
kind: pipeline # 定义一个管道
type: docker # 当前管道的类型
name: test # 当前管道的名称

volumes: # 声明数据卷(此为服务器中的实际目录)
  - name: node_modules # 数据卷名称
    host: # Host Volume
      path: /volumes/drone/volumes/blog/node_modules # 宿主机目录    #绝对路径
  - name: deploy_path
    host: 
      path: /workspace/blog

clone:
  disable: false # 启用代码拉取

steps: # 定义管道的执行步骤
  - name: deploy # 步骤名称
    image: node:16.13.2 # 当前步骤使用的镜像
    depends_on: [clone] # 依赖的步骤
    volumes: # 挂载数据卷(此为容器内的目录)
      - name: node_modules # 数据卷名称
        path: /drone/src/node_modules # 容器内目录 绝对路径
      - name: deploy_path
        path: /drone/src/html
    commands: # 当前步骤执行的命令
      - pwd # 查看当前目录
      - npm config set registry https://registry.npm.taobao.org # 切换淘宝镜像
      - npm install # 安装node_modules包
      - npm run build # 执行编译
      # - rm -fr ./blog
      - ls /drone/src
      - cp -r ./public/* ./html