docker版本
- drone:1.6.5
- drone-runner-docker:1
OAuth授權(quán)
- 登錄 https://github.com/settings/applications/new
- 根據(jù)drone 官方文檔操作
- 建立成功獲得 DRONE_GITHUB_CLIENT_ID,DRONE_GITHUB_CLIENT_SECRET
搭建 drone/drone-runner, docker-compose 集成
替換【】里面的內(nèi)容
version: '3'
services:
drone-server:
image: drone/drone:1.6.5
ports:
- 10080:80
volumes:
- /var/lib/drone:/var/lib/drone/
restart: always
environment:
- DRONE_GITHUB_CLIENT_ID=【注意:替換成上一節(jié)中的DRONE_GITHUB_CLIENT_ID】
- DRONE_GITHUB_CLIENT_SECRET=【注意:替換成上一節(jié)中的DRONE_GITHUB_CLIENT_SECRET】
- DRONE_RPC_SECRET=【openssl rand -hex 16 生成】
- DRONE_SERVER_HOST=drone.dev.huirongke.com:10080
- DRONE_SERVER_PROTO=http
- DRONE_WEBHOOK_SKIP_VERIFY=false
- DRONE_LOGS_DEBUG=true
- DRONE_USER_CREATE=username:【Git 倉庫當(dāng)前授權(quán)的賬號(hào)名】,admin:true
drone-runner:
image: drone/drone-runner-docker:1
restart: always
depends_on:
- drone-server
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DRONE_RPC_HOST=drone-server
- DRONE_RPC_PROTO=http
- DRONE_RPC_SECRET=【同上值 DRONE_RPC_SECRET】
- DRONE_RUNNER_CAPACITY=2
- DRONE_RUNNER_NAME=${HOSTNAME}
- DRONE_LOGS_DEBUG=true
掛載 Docker maven 到宿主
啟用 Drone Trusted: SETTINGS-Project settings-Trusted, 必須在 Drone 配置
DRONE_USER_CREATE=username:【Git 倉庫當(dāng)前授權(quán)的賬號(hào)名】,admin:true
吓懈,才有該菜單乐严。pipeline 的.drone.yml配置
steps:
- name: build
image: maven
volumes:
- name: cache # The Volume's name
path: /root/.m2 # The path in the container
commands:
#- mvn help:effective-settings # check maven
- mvn clean package -DskipTests
volumes:
- name: cache # The name use in this pipeline,
host:
path: /var/lib/cache # The path be used in the host.
使用 Aliyun Maven鏡像地址
在宿主機(jī)進(jìn)入/var/lib/cache
,新建settings.xml文件
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<localRepository>/Users/zhangdx/.m2/repository</localRepository>
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun</name>
<mirrorOf>central</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
<pluginGroups>
<pluginGroup>org.apache.maven.plugins</pluginGroup>
<pluginGroup>org.codehaus.mojo</pluginGroup>
</pluginGroups>
</settings>
啟動(dòng)檢查Drone
問題 or 坑
- Bitbucket OAuth 授權(quán)會(huì)獲取所有 Team 的項(xiàng)目,[尷尬]公司項(xiàng)目用的Bitbucket绷雏。
- Drone 的文檔真實(shí)爛,參數(shù)都不寫清楚,為了項(xiàng)目跑起來沐悦,直接Docker XXX inspect 調(diào)試配置。五督。藏否。