drone 学习五 集成gitlab 配置以及简单测试
备注:
使用docker-compose 进行安装 同时集成gitlab,预备环境 docker docker-compose gitlab
1. docker-compose
version: '3'
services:
drone-server:
image: drone/drone:0.8
ports:
- 8080:8000
- 9000
volumes:
- ./drone:/var/lib/drone/
restart: always
environment:
- DRONE_OPEN=true
- DRONE_HOST=http://10.15.0.66:8080 # 参考drone 配置
- DRONE_GITLAB=true
- DRONE_GITLAB_CLIENT=1e4484a41fc6bbc8504c79b629b8d3eaf8eb6bc902b13b984618e5e6360cabc5
- DRONE_GITLAB_SECRET=748192aa5a3fda23f1a6891039bb453f068d91102ff66a29d9656cde10a551ef
- DRONE_GITLAB_URL=YOUGITLAB
- DRONE_SECRET=appdemo
drone-agent:
image: drone/agent:0.8
restart: always
depends_on:
- drone-server
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DRONE_SERVER=drone-server:9000
- DRONE_SECRET=appdemo
备注: 上面的gitlab client secret 在gitlab 进行配置即可,这样就能集成gitlab 的认证以及访问了
2. 启动运行
备注: 我集成了jenkins
a. Jenkinsfile
pipeline {
agent {
node {
label 'docker-66'
}
}
stages {
stage('docker-compose build') {
steps {
sh 'docker-compose build'
}
}
stage('docker-compose run') {
steps {
sh 'docker-compose up -d '
}
}
}
}
3. 创建构建项目
参考 https://github.com/rongfengliang/drone-appdemo
主要是 .drone.yml (测试比较简单,只是简单的构建以及以来包的下载,实际需要考虑,发布,部署)
pipeline:
backend:
image: golang
commands:
- go build
- go test
frontend:
image: node:6
commands:
- npm install
- npm test
4. 运行&&启用drone ci
输入 http://dronehost:port 会跳转到 gitlab 认证页面,同意授权,并启动项目
5. 总结
对于使用容器开发的团队来说还是比较方便的,同时gitlab 本身也支持drone ci ,可以进行深度集成,灵活性上也不错,同时使用上也比较简单
6. 参考资料
http://docs.drone.io/installation/
http://docs.drone.io/getting-started/
https://github.com/rongfengliang/drone-appdemo