创建.gitlab-ci.yml配置文件,可以提交ci任务到gitlab-runner(docker模式)。
配置文件示例:
.gitlab-ci.yml1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| tages: - test - build - docker - deploy
test-example: stage: test script: - echo 'do some test here'
build-example: stage: build script: - echo 'do some build here'
docker-example: image: "docker:dind" stage: docker when: on_success dependencies: - build only: - /^.*-release$/ script: - export IMAGE_NAME=mapleque/${CI_PROJECT_PATH}:${CI_COMMIT_REF_NAME} - docker build -t ${IMAGE_NAME} <Dockerfile path> && docker push ${IMAGE_NAME}
deploy-example: image: "mapleque/deploy" stage: deploy when: on_success dependencies: [] only: - /^.*-release$/ environment: name: release script: - export DEPLOY_CONFIG_TYPE=kubernates - export DEPLOY_CONFIG_TARGET=example.mapleque.com - export DEPLOY_CONFIG_TOKEN=${DEPLOY_TOKEN} - export DEPLOY_CONFIG_IMAGE=mapleque/${CI_PROJECT_PATH}:${CI_COMMIT_REF_NAME} - deploy
|