<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Gitlab on My Blog</title><link>/tags/gitlab/</link><description>Recent content in Gitlab on My Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 22 Jul 2016 00:00:00 +0000</lastBuildDate><atom:link href="/tags/gitlab/index.xml" rel="self" type="application/rss+xml"/><item><title>Gitlab CI</title><link>/2016/07/22/gitlab-ci/</link><pubDate>Fri, 22 Jul 2016 00:00:00 +0000</pubDate><guid>/2016/07/22/gitlab-ci/</guid><description>&lt;!-- toc --&gt;
&lt;p&gt;[TOC]&lt;/p&gt;
&lt;h1 id="gitlab-ci-cd"&gt;GitLab CI CD&lt;/h1&gt;
&lt;p&gt;&lt;strong&gt;持续集成(Continuous Integration)&lt;/strong&gt; , 合并存储库中的更改之前触发管道来构建，测试和验证新代码。就是先测试和验证代码，然后再合并。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;持续交付(Continuous Delivery）&lt;/strong&gt; 将CI验证的代码&lt;strong&gt;交付&lt;/strong&gt;给您的应用程序。就是将合并的代码更新部署到线上。&lt;/p&gt;
&lt;h2 id="cicd的优点"&gt;CI/CD的优点：&lt;/h2&gt;
&lt;h3 id="持续集成"&gt;持续集成&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;尽快发现错误：&lt;/strong&gt; 在开发人员重新思考的同时解决问题&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;减少集成问题：&lt;/strong&gt; 更小的问题更容易消化&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;避免复杂的问题：&lt;/strong&gt; 使团队更加自信地发展更快&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="持续交付"&gt;持续交付&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;确保每个更改都是可发布的：&lt;/strong&gt; 在完成之前测试所有内容，包括部署&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;降低每次发布的风险：&lt;/strong&gt; 使发布简单&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;更加频繁地交付价值：&lt;/strong&gt; 可靠的部署意味着更多的发布&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;紧密的客户反馈循环：&lt;/strong&gt; 快速而频繁的客户对变更的反馈&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;参考：https://about.gitlab.com/product/continuous-integration/&lt;/p&gt;
&lt;h2 id="gitlab-runner"&gt;GitLab Runner&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;GitLab Runner&lt;/strong&gt; 是一个处理构建的应用程序。它可以单独部署，并通过API与GitLab CI / CD一起使用。为了让你提交的代码自动执行构建，测试和部署等功能，你需要有一个可以执行构建测试和部署的服务，Gitlab Runner就是这么一个服务。&lt;/p&gt;
&lt;h3 id="install"&gt;install&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;添加官方的安装源&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;# 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
&lt;/code&gt;&lt;/pre&gt;&lt;ol start="2"&gt;
&lt;li&gt;安装gitlab-runner&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;# For Debian/Ubuntu/Mint
sudo apt-get install gitlab-runner
# For RHEL/CentOS/Fedora
sudo yum install gitlab-runner
&lt;/code&gt;&lt;/pre&gt;&lt;ol start="3"&gt;
&lt;li&gt;修改配置，链接到Gitlab&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;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
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;参考：&lt;/p&gt;</description></item><item><title>gitlab</title><link>/2016/07/12/gitlab/</link><pubDate>Tue, 12 Jul 2016 00:00:00 +0000</pubDate><guid>/2016/07/12/gitlab/</guid><description>&lt;!-- toc --&gt;
&lt;p&gt;[TOC]&lt;/p&gt;
&lt;h1 id="gitlab"&gt;GitLab&lt;/h1&gt;
&lt;p&gt;&lt;strong&gt;GitLab&lt;/strong&gt;是用Ruby开发的完全免费的开源软件，按照 MIT 许可证分发的Git仓库管理工具，且具有wiki和issue跟踪功能。特别适合公司搭建自己的Git仓库，可局域网使用。&lt;/p&gt;
&lt;h2 id="install"&gt;install&lt;/h2&gt;
&lt;p&gt;如果不是特大公司，千人以上的开发人员。中小型企业直接使用docker运行gitlab基本是足够的了，公司使用两三年了，基本没有遇到什么问题。&lt;/p&gt;
&lt;p&gt;运行示例：&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;docker pull gitlab-ce:9.5.10-ce.0
docker run --detach \
--hostname git.domain.com \
--env GITLAB_OMNIBUS_CONFIG=&amp;#34;external_url &amp;#39;https://git.domain.com/&amp;#39;;&amp;#34; \
--env GITLAB_HOST=&amp;#34;git.domain.com&amp;#34; \
--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
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="backup"&gt;backup&lt;/h2&gt;
&lt;p&gt;备份很简单，&lt;code&gt;itlab-rake gitlab:backup:create&lt;/code&gt; 即可搞定，备份以&lt;code&gt;tar&lt;/code&gt; 压缩包保存。格式如下：&lt;/p&gt;
&lt;p&gt;&lt;code&gt;1545649962_2017_12_24_9.5.10_gitlab_backup.tar&lt;/code&gt; ，中间有备份时间和gitlab版本。docker备份：&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;docker exec -t gitlab gitlab-rake gitlab:backup:create
ls /gitlab/data/backups/1545649962_2017_12_24_9.5.10_gitlab_backup.tar
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="restore"&gt;restore&lt;/h2&gt;
&lt;p&gt;恢复必须在相同的gitlab版本上面，比如上面的例子是在 9.5.10&lt;/p&gt;</description></item></channel></rss>