{"id":1690,"date":"2023-03-25T11:48:30","date_gmt":"2023-03-25T03:48:30","guid":{"rendered":""},"modified":"2023-03-25T11:48:30","modified_gmt":"2023-03-25T03:48:30","slug":"GitLab \u5b89\u88c5","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/1690.html","title":{"rendered":"GitLab \u5b89\u88c5"},"content":{"rendered":"


\n <\/head>
\n <\/p>\n

\n

GitLab \u5b89\u88c5<\/h1>\n<\/p><\/div>\n
\n \u60a8\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5b89\u88c5 GitLab \u8fd0\u884c\u7a0b\u5e8f\uff0c\u65b9\u6cd5\u662f\u5b89\u88c5
\n Git<\/i> \u7248\u672c\u63a7\u5236\u7cfb\u7edf\u5e76\u5728 GitLab \u7ad9\u70b9\u4e2d\u521b\u5efa\u7528\u6237\u5e10\u6237\u3002\n <\/div>\n
\n Git<\/i> \u662f\u4e00\u4e2a\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u7528\u4e8e-\n <\/div>\n

\u5904\u7406\u9879\u76ee\u7684\u6e90\u4ee3\u7801\u5386\u53f2<\/span>
\n \u8ddf\u8e2a\u5bf9\u6587\u4ef6\u6240\u505a\u7684\u66f4\u6539<\/span>
\n \u5feb\u901f\u9ad8\u6548\u5730\u5904\u7406\u5927\u5c0f\u9879\u76ee<\/span>
\n \u5728\u4e0d\u540c\u7684\u9879\u76ee\u4e0a\u4e0e\u5176\u4ed6\u5f00\u53d1\u8005\u5408\u4f5c<\/span> <\/p>\n

\n GitLab<\/i> \u662f\u4e00\u4e2a\u57fa\u4e8e Git \u7684\u5e73\u53f0\uff0c\u63d0\u4f9b\u5bf9 Git \u5b58\u50a8\u5e93\u7684\u8fdc\u7a0b\u8bbf\u95ee\uff0c\u5e76\u901a\u8fc7\u521b\u5efa\u7528\u4e8e\u7ba1\u7406\u4ee3\u7801\u7684\u79c1\u6709\u548c\u516c\u5171\u5b58\u50a8\u5e93\u6765\u5e2e\u52a9\u8f6f\u4ef6\u5f00\u53d1\u5468\u671f\u3002\n <\/div>\n
\n GitLab \u652f\u6301\u4e0d\u540c\u7c7b\u578b\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u4f8b\u5982 Windows\u3001Ubuntu\u3001Debian\u3001CentOS\u3001open SU\u200b\u200bSE \u548c Raspberry Pi 2\u3001\u5728\u672c\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba\u5982\u4f55\u5728 Windows \u548c Ubuntu \u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5b89\u88c5 GitLab-\n <\/div>\n

\u5728 Windows \u4e0a\u5b89\u88c5 GitLab\uff1a<\/h2>\n
\n \u6b65\u9aa4 1<\/b>-\u9996\u5148\u5728\u60a8\u7684\u7cfb\u7edf\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"GitLab-Runner\"\u7684\u6587\u4ef6\u5939\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u5728 C \u76d8\u4e2d\u521b\u5efa\u4e3a C:\\GitLab-Runner\u3002\n <\/div>\n
\n \u7b2c 2 \u6b65<\/b>-\u73b0\u5728\u4e0b\u8f7d x86 \u6216 amd64 \u5e76\u5c06\u5176\u590d\u5236\u5230\u60a8\u521b\u5efa\u7684\u6587\u4ef6\u5939\u4e2d\u3002\u5c06\u4e0b\u8f7d\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u91cd\u547d\u540d\u4e3a
\n gitlab-runner.exe<\/i>\u3002\n <\/div>\n
\n \u6b65\u9aa4 3<\/b>-\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u5e76\u5bfc\u822a\u5230\u60a8\u521b\u5efa\u7684\u6587\u4ef6\u5939\u3002\u73b0\u5728\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u6309\u56de\u8f66\u952e\u3002\n <\/div>\n
\n
C:\\GitLab-Runner>gitlab-runner.exe register\n<\/pre>\n

<\/code>\n <\/div>\n

\n \u7b2c 4 \u6b65<\/b>-\u8fd0\u884c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0c\u5b83\u4f1a\u8981\u6c42\u8f93\u5165 gitlab-ci \u534f\u8c03\u5668 URL\u3002\n <\/div>\n
\n
Please enter the gitlab-ci coordinator URL (e.g. https:\/\/gitlab.com<\/span>\/):<\/span>\nhttps:\/\/gitlab.com\n<\/pre>\n

<\/code>\n <\/div>\n

\n \u6b65\u9aa4 5<\/b>-\u8f93\u5165\u8dd1\u6b65\u8005\u7684 gitlab-ci \u4ee4\u724c\u3002\n <\/div>\n
\n
Please enter the gitlab-ci token for <\/span>this<\/span> runner:\nxxxxx\n<\/pre>\n

<\/code>\n <\/div>\n

<\/p>\n

\n \u8981\u83b7\u53d6\u4ee4\u724c\uff0c\u8bf7\u767b\u5f55\u60a8\u7684 GitLab \u5e10\u6237-\n <\/div>\n

<\/span>
\n GitLab \u5b89\u88c5_https:\/\/bianchenghao6.com_\u3010GitLab \u6559\u7a0b\u3011_\u7b2c1\u5f20
\n <\/p>\n

\n \u73b0\u5728\u53bb\u4f60\u7684\u9879\u76ee-\n <\/div>\n

<\/span>
\n GitLab \u5b89\u88c5_https:\/\/bianchenghao6.com_\u3010GitLab \u6559\u7a0b\u3011_\u7b2c2\u5f20
\n <\/p>\n

\n \u70b9\u51fb
\n \u8bbe\u7f6e<\/i>\u6807\u7b7e\u4e0b\u7684
\n CI\/CD<\/i>\u9009\u9879\u5e76\u5c55\u5f00
\n Runners\u8bbe\u7f6e<\/i>\u9009\u9879\u3002\n <\/div>\n

<\/span>
\n GitLab \u5b89\u88c5_https:\/\/bianchenghao6.com_\u3010GitLab \u6559\u7a0b\u3011_\u7b2c3\u5f20
\n <\/p>\n

\n \u5728
\n Runners Settings<\/i> \u90e8\u5206\u4e0b\uff0c\u60a8\u5c06\u83b7\u5f97\u5982\u4e0b\u56fe\u6240\u793a\u7684\u4ee4\u724c-\n <\/div>\n

<\/span>
\n GitLab \u5b89\u88c5_https:\/\/bianchenghao6.com_\u3010GitLab \u6559\u7a0b\u3011_\u7b2c4\u5f20 <\/p>\n

\n \u6b65\u9aa4 6<\/b>-\u8f93\u5165\u8dd1\u6b65\u8005\u7684 gitlab-ci \u63cf\u8ff0\u3002\n <\/div>\n
\n
Please enter the gitlab-ci description for <\/span>this<\/span> runner:\n[Admin-PC]: Hello GitLab Runner\n<\/pre>\n

<\/code>\n <\/div>\n

\n \u7b2c 7 \u6b65<\/b>-\u5b83\u5c06\u8981\u6c42\u8f93\u5165\u8dd1\u6b65\u8005\u7684 gitlab-ci \u6807\u7b7e\u3002\n <\/div>\n
\n
Please enter the gitlab-ci tags for <\/span>this<\/span> runner (comma separated):\ntag1, tag2\n<\/pre>\n

<\/code>\n <\/div>\n

\n \u60a8\u53ef\u4ee5\u7a0d\u540e\u5728 GitLab \u7684\u7528\u6237\u754c\u9762\u4e2d\u66f4\u6539\u8fd9\u4e9b\u6807\u7b7e\u3002\n <\/div>\n
\n \u6b65\u9aa4 8<\/b>-\u60a8\u53ef\u4ee5\u901a\u8fc7\u5c06 Runner \u8bbe\u7f6e\u4e3a\u771f\u503c\u6765\u5c06\u5176\u9501\u5b9a\u5230\u5f53\u524d\u9879\u76ee\u3002\n <\/div>\n
\n
Whether to lock the Runner to current project [true\/false]:\n[true]: true<\/span><\/span>\n<\/pre>\n

<\/code>\n <\/div>\n

\n \u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0c\u60a8\u5c06\u6536\u5230\"\u6ce8\u518c\u8dd1\u6b65\u8005...\u6210\u529f\"\u7684\u6210\u529f\u4fe1\u606f\u3002\n <\/div>\n
\n \u7b2c 9 \u6b65<\/b>-\u73b0\u5728\u8fdb\u5165\u7528\u4e8e\u6784\u5efa\u9879\u76ee\u7684 Runner \u6267\u884c\u5668\u3002\n <\/div>\n
\n
Please enter the executor: parallels, shell, docker+machine, kubernetes, docker-\nssh+machine, docker, docker-ssh, ssh, virtualbox:\ndocker\n<\/pre>\n

<\/code>\n <\/div>\n

\n \u6211\u4eec\u5c06\u9009\u62e9\u5668\u7528\u4f5c\"docker\"\uff0c\u5b83\u521b\u5efa\u6784\u5efa\u73af\u5883\u5e76\u8f7b\u677e\u7ba1\u7406\u9879\u76ee\u5f00\u53d1\u6240\u9700\u7684\u4f9d\u8d56\u9879\u3002\n <\/div>\n
\n \u6b65\u9aa4 10<\/b>-\u63a5\u4e0b\u6765\u5b83\u5c06\u8981\u6c42\u4e3a docker \u9009\u62e9\u5668\u8bbe\u7f6e\u9ed8\u8ba4\u56fe\u50cf\u3002\n <\/div>\n
\n
Please enter the default <\/span>Docker image (e.g. ruby:2.1):\nalpine:latest\n<\/pre>\n

<\/code>\n <\/div>\n

\n \u6b65\u9aa4 11<\/b>-\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0c\u5c06\u663e\u793a\u6d88\u606f\"Runner \u6ce8\u518c\u6210\u529f\"\u3002\u4e0b\u56fe\u5c06\u63cf\u8ff0\u4e0a\u8ff0\u547d\u4ee4\u7684\u5de5\u4f5c\u6d41\u7a0b-\n <\/div>\n

GitLab \u5b89\u88c5_https:\/\/bianchenghao6.com_\u3010GitLab \u6559\u7a0b\u3011_\u7b2c5\u5f20 <\/p>\n

\n Step 12<\/b>-\u73b0\u5728\u8f6c\u5230\u60a8\u7684\u9879\u76ee\uff0c\u5355\u51fb
\n Settings<\/i> \u90e8\u5206\u4e0b\u7684
\n CI\/CD<\/i> \u9009\u9879\uff0c\u60a8\u5c06\u770b\u5230\u6fc0\u6d3b\u7684 Runners\u7528\u4e8e\u9879\u76ee\u3002\n <\/div>\n

GitLab \u5b89\u88c5_https:\/\/bianchenghao6.com_\u3010GitLab \u6559\u7a0b\u3011_\u7b2c6\u5f20 <\/p>\n

\n \u60a8\u53ef\u4ee5\u5728
\n GitLab-Runner<\/i> \u6587\u4ef6\u5939\u4e0b\u7684
\n config.toml<\/i> \u6587\u4ef6\u4e2d\u770b\u5230 GitLab Runner \u914d\u7f6e\uff0c\u5982\u4e0b\u6240\u793a-\n <\/div>\n
\n
concurrent = 1\ncheck_interval = 0\n[[runners]]\n  name = \"Hello GitLab Runner\"<\/span>\n  url = \"https:\/\/gitlab.com\"<\/span><\/span>\n  token = \"40ceed29eec231fa9e306629cae4d7\"<\/span>\n  executor = \"docker\"<\/span>\n  [runners.docker]\n      tls_verify = false<\/span>\n      image = \"alpine:latest\"<\/span>\n      privileged = false<\/span>\n      disable_cache = false<\/span>\n      volumes = [\"\/cache\"<\/span>]\n      shm_size = 0\n  [runners.cache]\n<\/pre>\n

<\/code>\n <\/div>\n

\u5728 Ubuntu \u4e0a\u5b89\u88c5 GitLab<\/h2>\n
\n GitLab \u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528
\n Omnibus<\/i> \u5305\u5b89\u88c5\u5728 Ubuntu \u7cfb\u7edf\u4e0a\uff0c\u8be5\u5305\u63d0\u4f9b\u4e0d\u540c\u7684\u670d\u52a1\u6765\u8fd0\u884c GitLab\u3002 Omnibus \u5305\u63d0\u4f9b\u4e86 GitLab \u7684\u5fc5\u8981\u7ec4\u4ef6\uff0c\u5efa\u7acb\u4e86\u53ef\u4ee5\u5728\u7528\u6237\u7cfb\u7edf\u4e2d\u4f7f\u7528\u7684\u914d\u7f6e\u548c\u9879\u76ee\u5143\u6570\u636e\u3002\n <\/div>\n
\n \u4ee5\u4e0b\u6b65\u9aa4\u63cf\u8ff0\u4e86\u5728 Ubuntu \u4e0a\u5b89\u88c5 GitLab-\n <\/div>\n
\n \u6b65\u9aa4 1<\/b>-\u9996\u5148\uff0c\u4f7f\u7528 SSH\uff08\u5b89\u5168\u5916\u58f3\uff09\u767b\u5f55\u5230\u60a8\u7684 GitLab \u670d\u52a1\u5668\u3002\n <\/div>\n
\n \u6b65\u9aa4 2<\/b>-\u63a5\u4e0b\u6765\uff0c\u4e0b\u8f7d Omnibus \u5305-\n <\/div>\n
\n
wget https:\/\/downloads-packages.s3.amazonaws.com\/ubuntu-14.04\/gitlab-ce_7.10.4~omnibus-1_amd64.deb<\/span>\n<\/pre>\n

<\/code>\n <\/div>\n

GitLab \u5b89\u88c5_https:\/\/bianchenghao6.com_\u3010GitLab \u6559\u7a0b\u3011_\u7b2c7\u5f20 <\/p>\n

\n \u6b65\u9aa4 3<\/b>-\u5b89\u88c5\u540e\u7f00-\n <\/div>\n
\n
sudo <\/span>apt-get install postfix\n<\/pre>\n

<\/code>\n <\/div>\n

\n Postfix \u662f\u4e00\u4e2a\u5f00\u6e90\u90ae\u4ef6\u4f20\u8f93\u4ee3\u7406\uff0c\u7528\u4e8e\u53d1\u9001\u7535\u5b50\u90ae\u4ef6\u901a\u77e5\u3002\n <\/div>\n

GitLab \u5b89\u88c5_https:\/\/bianchenghao6.com_\u3010GitLab \u6559\u7a0b\u3011_\u7b2c8\u5f20 <\/p>\n

\n Step 4<\/b>-\u5728\u5b89\u88c5 Postfix \u65f6\uff0c\u5b83\u4f1a\u8be2\u95ee\u5b89\u88c5\u7c7b\u578b\uff1b\u7136\u540e\u9009\u62e9
\n Internet \u7ad9\u70b9<\/i> \u9009\u9879\u3002\u63a5\u4e0b\u6765\uff0c\u5b83\u5c06\u663e\u793a Postfix \u914d\u7f6e\u4ee5\u53ca\u7cfb\u7edf\u90ae\u4ef6\u540d\u79f0\uff0c\u5982\u56fe\u6240\u793a-\n <\/div>\n

GitLab \u5b89\u88c5_https:\/\/bianchenghao6.com_\u3010GitLab \u6559\u7a0b\u3011_\u7b2c9\u5f20 <\/p>\n

\n \u6b65\u9aa4 5<\/b>-\u5b89\u88c5 dpkg\uff08debian \u7cfb\u7edf\u7684\u5305\u7ba1\u7406\u5668\uff09\u4ee5\u7ba1\u7406\u5df2\u5b89\u88c5\u7684\u5305-\n <\/div>\n
\n
sudo <\/span>dpkg-i gitlab-ce_7.10.4~omnibus-1_amd64.deb\n<\/pre>\n

<\/code>\n <\/div>\n

GitLab \u5b89\u88c5_https:\/\/bianchenghao6.com_\u3010GitLab \u6559\u7a0b\u3011_\u7b2c10\u5f20 <\/p>\n

\n \u6b65\u9aa4 6<\/b>-\u8981\u4f7f\u66f4\u6539\u751f\u6548\uff0c\u60a8\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u65b0\u914d\u7f6e GitLab-\n <\/div>\n
\n
sudo <\/span>gitlab-ctl reconfigure\n<\/pre>\n

<\/code>\n <\/div>\n

\n \u6b65\u9aa4 7<\/b>-\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5 GitLab \u670d\u52a1\u7684\u72b6\u6001-\n <\/div>\n
\n
sudo <\/span>gitlab-ctl status\n<\/pre>\n

<\/code>\n <\/div>\n

\n \u5982\u679c\u4f60\u60f3\u4ece\u6e90\u7801\u5b89\u88c5 GitLab\uff0c\u90a3\u4e48\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u4e00\u4e9b\u4f9d\u8d56\u9879\uff0c\u9700\u8981\u4f7f\u7528 PostgreSQL \u8bbe\u7f6e\u6570\u636e\u5e93\u3002\u5b83\u5728\u73af\u5883\u8bbe\u7f6e\u4e00\u7ae0\u4e2d\u6709\u63cf\u8ff0\u3002\u60a8\u53ef\u4ee5\u5b89\u88c5\u534f\u8c03\u5668\u6765\u6784\u5efa Web \u754c\u9762\u5e76\u63a7\u5236\u6784\u5efa\u5b9e\u4f8b\u3002\u6709\u5173\u66f4\u591a\u4fe1\u606f\uff0c\u60a8\u53ef\u4ee5\u67e5\u770bCoordinator \u7684\u5b89\u88c5\u7ae0\u8282\u3002\n <\/div>\n

<\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"GitLab \u5b89\u88c5zh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[151],"tags":[],"class_list":["post-1690","post","type-post","status-publish","format-standard","hentry","category-gitlabjc"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/1690"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=1690"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/1690\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=1690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=1690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=1690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}