在Ubuntu上实现GitLab持续集成,可按以下步骤操作:
docker pull gitlab/gitlab-runner:latest
,然后运行docker run -d --name gitlab-runner --restart always -v /var/run/docker.sock:/var/run/docker.sock -v gitlab-runner-config:/etc/gitlab-runner gitlab/gitlab-runner:latest
。也可通过包管理器安装,如sudo apt-get install gitlab-ci-multi-runner
。gitlab-runner register
命令进行注册,需指定执行器、镜像等信息。stages:
- build
- test
- deploy
build_job:
stage: build
script:
- echo "Building the project..."
test_job:
stage: test
script:
- echo "Running tests..."
deploy_job:
stage: deploy
script:
- echo "Deploying the project..."
only:
- master