gitlab-ci 测试实例
1.gitlab 安装部署
2.gitlab-runner 部署
配置
/data/gitlab-runner/config/config.toml
image = "docker:latest"
volumes = ["/cache","/var/run/docker.sock:/var/run/docker.sock","/data/ledou-git:/data/ledou-git"]
pull_policy = "if-not-present"
#仓库地址的映射
"/data/ledou-git:/data/ledou-git"
重启
docker restart gitlab-runner
3.仓库信息
/data/ledou-git/ledou/.gitlab-ci.yml
stages:
- test
- build
- deploy
variables:
IMAGE: nginx:1.11-alpine
before_script:
- IMAGE_TAG=v1.0
test_all:
stage: test
tags:
- nginx:1.11-alpine
script:
- cd /tmp
- echo `date +%Y-%m-%d_%H:%M:%S` >> index.html
build_image:
# image: nginx:1.11-alpine
image: docker:latest
stage: build
tags:
- nginx:1.11-alpine
script:
- cd /data/ledou-git/ledou
- docker build -t ledou-${IMAGE_TAG} -f Dockerfile .
deploy_production:
stage: deploy
tags:
- nginx:1.11-alpine
script:
- cd /data/ledou-git/ledou
- echo `date +%Y-%m-%d_%H:%M:%S` >> ledou.log
4.输出显示
注意
tags:
- nginx:1.11-alpine
执行显示