Gitlab CI

[TOC] GitLab CI CD 持续集成(Continuous Integration) , 合并存储库中的更改之前触发管道来构建,测试和验证新代码。就是先测试和验证代码,然后再合并。 持续交付(Continuous Delivery) 将CI验证的代码交付给您的应用程序。就是将合并的代码更新部署到线上。 CI/CD的优点: 持续集成 尽快发现错误: 在开发人员重新思考的同时解决问题 减少集成问题: 更小的问题更容易消化 避免复杂的问题: 使团队更加自信地发展更快 持续交付 确保每个更改都是可发布的: 在完成之前测试所有内容,包括部署 降低每次发布的风险: 使发布简单 更加频繁地交付价值: 可靠的部署意味着更多的发布 紧密的客户反馈循环: 快速而频繁的客户对变更的反馈 参考:https://about.gitlab.com/product/continuous-integration/ GitLab Runner GitLab Runner 是一个处理构建的应用程序。它可以单独部署,并通过API与GitLab CI / CD一起使用。为了让你提交的代码自动执行构建,测试和部署等功能,你需要有一个可以执行构建测试和部署的服务,Gitlab Runner就是这么一个服务。 install 添加官方的安装源 # For Debian/Ubuntu/Mint curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash # For RHEL/CentOS/Fedora curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash 安装gitlab-runner # For Debian/Ubuntu/Mint sudo apt-get install gitlab-runner # For RHEL/CentOS/Fedora sudo yum install gitlab-runner 修改配置,链接到Gitlab Run the following command: sudo gitlab-runner register Enter your GitLab instance URL: Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com ) https://gitlab.com Enter the token you obtained to register the Runner: Please enter the gitlab-ci token for this runner xxx Enter a description for the Runner, you can change this later in GitLab’s UI: Please enter the gitlab-ci description for this runner [hostname] my-runner Enter the tags associated with the Runner, you can change this later in GitLab’s UI: Please enter the gitlab-ci tags for this runner (comma separated): my-tag,another-tag Enter the Runner executor: Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell: docker If you chose Docker as your executor, you’ll be asked for the default image to be used for projects that do not define one in .gitlab-ci.yml: Please enter the Docker image (eg. ruby:2.1): alpine:latest 参考: ...

July 22, 2016

gitlab

[TOC] GitLab GitLab是用Ruby开发的完全免费的开源软件,按照 MIT 许可证分发的Git仓库管理工具,且具有wiki和issue跟踪功能。特别适合公司搭建自己的Git仓库,可局域网使用。 install 如果不是特大公司,千人以上的开发人员。中小型企业直接使用docker运行gitlab基本是足够的了,公司使用两三年了,基本没有遇到什么问题。 运行示例: docker pull gitlab-ce:9.5.10-ce.0 docker run --detach \ --hostname git.domain.com \ --env GITLAB_OMNIBUS_CONFIG="external_url 'https://git.domain.com/';" \ --env GITLAB_HOST="git.domain.com" \ --publish 80:80 \ --publish 2289:22 \ --name gitlab \ --restart always \ --volume /gitlab/config:/etc/gitlab \ --volume /gitlab/logs:/var/log/gitlab \ --volume /gitlab/data:/var/opt/gitlab \ --log-opt max-size=100m --log-opt max-file=10 \ gitlab-ce:9.5.10-ce.0 backup 备份很简单,itlab-rake gitlab:backup:create 即可搞定,备份以tar 压缩包保存。格式如下: 1545649962_2017_12_24_9.5.10_gitlab_backup.tar ,中间有备份时间和gitlab版本。docker备份: docker exec -t gitlab gitlab-rake gitlab:backup:create ls /gitlab/data/backups/1545649962_2017_12_24_9.5.10_gitlab_backup.tar restore 恢复必须在相同的gitlab版本上面,比如上面的例子是在 9.5.10 ...

July 12, 2016