设置无人机与github的持续集成

时间:2017-03-04 18:03:07

标签: docker continuous-integration drone drone.io

我正在尝试使用无人机(开源版)在企业网络内部设置CI服务器。它的作者将无人机描述为一个非常简单的解决方案,即使对于程序员来说(就像我一样),虽然有些时刻对我来说并不清楚(可能是官方文档错过了它们)。

首先,我为rails应用程序编写了一个docker镜像:rails-qna。 接下来,编写无人机图像:

搬运工-compose.yml:

version: '2'

services:
  drone-server:
    image: drone/drone:0.5
    ports:
     - 80:8000
    volumes:
     - ./drone:/var/lib/drone/
    restart: always
    environment:
     - DRONE_OPEN=true
     - DRONE_ADMIN=khataev
     - DRONE_GITHUB_CLIENT=github-client-string
     - DRONE_GITHUB_SECRET=github-secret-string
     - DRONE_SECRET=drone-secret-string

  drone-agent:
    image: drone/drone:0.5
    command: agent
    restart: always
    depends_on: [ drone-server ]
    volumes:
     - /var/run/docker.sock:/var/run/docker.sock
    environment:
     - DRONE_SERVER=ws://drone-server:8000/ws/broker
     - DRONE_SECRET=drone-secret-string

应用程序在Github上注册,并提供了秘密/客户端字符串。

我将.drone.yml文件放入我的项目存储库:

pipeline:
  build:
    image: rails-qna
    commands: 
      - bundle exec rake db:drop
      - bundle exec rake db:create
      - bundle exec rake db:migrate
      - bundle exec rspec

不清楚的时刻: 1)在github上注册OAuth应用程序时,我们应该指定主页URL和授权回调URL。他们应该指向哪里?无人机服务器容器?猜测是这样,我指定 mycorporatedomain.com:3005 和 mycorporatedomain.com:3005/authorize 并设置端口从3005端口转发到主机的80端口,无人机停靠器正在运行。可能是我错了?

2)我应该在密钥DRONE_GITHUB_URL中指定什么? https://github.com或我的项目存储库的完整路径,即 https://github.com/khataev/qna

3)如果我想构建除master之外的某个分支怎么办?我应该指定它吗?现在无人机就绪分支(带.drone.yml)不是主分支 - 它会起作用吗?

4)为什么DRONE_GITHUB_GIT_USERNAME和DRONE_GITHUB_GIT_PASSWORD是optional?如果我没有为我的github帐户指定用户名和密码,它应该如何工作?

5)当我用docker启动无人机图像时,我收到了这个错误:

→ docker-compose up
Starting drone_drone-server_1
Starting drone_drone-agent_1
Attaching to drone_drone-server_1, drone_drone-agent_1
drone-server_1  | time="2017-03-04T17:00:33Z" level=fatal msg="version control system not configured" 
drone-agent_1   | 1:M 04 Mar 17:00:35.208 * connecting to server ws://drone-server:8000/ws/broker
drone-agent_1   | 1:M 04 Mar 17:00:35.229 # connection failed, retry in 15s. websocket.Dial ws://drone-server:8000/ws/broker: dial tcp: lookup drone-server on 127.0.0.11:53: no such host
drone_drone-server_1 exited with code 1
drone-server_1  | time="2017-03-04T16:53:38Z" level=fatal msg="version control system not configured" 

UPD 5)这个问题解决了 - 忘了指定

DRONE_GITHUB=true

1 个答案:

答案 0 :(得分:2)

  1. 主页URL是运行无人机的服务器的地址。 例如。 http://155.200.100.0 授权URL与/ authorize附加的地址相同 例如。 http://155.200.100.0/authorize

  2. 你不必指定它。 DRONE_GITHUB = true表示无人机使用github url。

  3. 您可以将单个部分限制为分支或整个无人机版本。

  4. 单节:

    pipeline:
      build:
        image: node:latest
        commands:
          - npm install 
          - npm test
        when:
          branch: master
    

    整个构建过程:

    pipeline:
      build:
        image: node:latest
        commands:
          - npm install
          - npm test
    
    branches: master
    
    1. 使用OAuth时不需要用户名和密码。
    2. 来源:

      http://readme.drone.io/admin/setup-github/

      http://readme.drone.io/usage/skipping-builds/

      http://readme.drone.io/usage/skipping-build-steps/

      更新:

      由于Drone版本0.6

      ,文档已转移到http://docs.drone.io/