机器人 救救瓜
Toggle navigation
Home
SCM-tool
Linux
Jenkins
SVN
other
About Me
Archives
Tags
gitlab CI/CD
? gitlab ?
2019-03-27 14:56:31
484
0
0
gua_l
? gitlab ?
</br> ##### 写在前面 ---------- gitlab 的CI/CD ,即持续集成,持续构建并部署测试的过程,实质上是 1. 将持续集成的过程阶段(编译构建/打包/部署/测试)写在gitlab.yml中 2. 并将准备执行gitlab.yml脚本内容的服务器配置为gitlab服务器的一个runner。 3. 当gitlab 库中的提交时,便会自动触发一次在runner 上的持续集成过程。 ---------- </br> ## 创建 gitlab-ci.yml *注意: gitlab.yml 是一个yaml文件,对缩进非常严格,需要始终使用空格,而非制表符。* https://gitlab.${company}.com/help/ci/yaml/README.md 具体格式及构成可参考gitlab help/ci/yaml/README.md 文件 在库中的根目录下,创建一个名为.gitlab.yml的文件 1. 通过 CI-CD --> jobs --> CI Init 直接编辑初始化文件 2. 在库中的根目录下,创建一个名为.gitlab.yml的文件 ## 配置库的CI/CD 在库的设置中Setting--> CI/CD --> runners 展开 使用共享 runner 去运行 : Shared Runners 使用指定 runner 去运行 : Specific Runners //如从新配置一台服务器作为gitlab.yml 中脚本运行的runner,请按如下配置runner执行 ## 配置 Runner > https://docs.gitlab.com/runner/install/ 安装GitLab Runner # Linux x86-64 sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 赋执行权限 sudo chmod +x /usr/local/bin/gitlab-runner 创建 GitLab CI 用户: sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash 安装并运行服务 sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner sudo gitlab-runner start 注册runner # https://docs.gitlab.com/runner/register/index.html # 用到在库的设置中的信息 # Setting-CI/CD-runners -->Specific Runners Specify the following URL during the Runner setup: https://gitlab.xxxxx.com/ Use the following registration token during setup: ot8AZsG1ZxxxxxxsSs </br> .gitlab-ci.yml ``` stages: - build build image: stage: build before_script: - docker login -u $username -p $passwd $CI_REGISTRY script: - docker build . -t dibenv - docker tag dibenv registry.gitlab.xxxxx.com/releaseprocess/dib-env/dibenv:CDJOB_${CI_JOB_ID} - docker tag dibenv registry.gitlab.xxxxx.com/releaseprocess/dib-env/dibenv:latest - docker push registry.gitlab.xxxxx.com/releaseprocess/dib-env/dibenv:CDJOB_${CI_JOB_ID} - docker push registry.gitlab.xxxxx.com/releaseprocess/dib-env/dibenv:latest tags: - docker only: - master ``` </br>
Pre:
Redhatl 7.1 安装 pip
Next:
git 撤销操作
0
likes
484
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
Table of content
No Leanote account? Sign up now.