From 118d771cd184a7590052362cbd7653494d4a47b7 Mon Sep 17 00:00:00 2001 From: wusuopu Date: Sun, 15 Oct 2023 09:17:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E6=96=87=E7=AB=A0:=2084184?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-Runner-\351\205\215\347\275\256.markdown" | 2 +- ...-Runner-\351\205\215\347\275\256.markdown" | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 "source/_posts/2023-10-14-84184-Bitbucket-Runner-\351\205\215\347\275\256.markdown" diff --git "a/source/_posts/2021-04-13-84182-Gitlab-Runner-\351\205\215\347\275\256.markdown" "b/source/_posts/2021-04-13-84182-Gitlab-Runner-\351\205\215\347\275\256.markdown" index 91e33958..af747307 100644 --- "a/source/_posts/2021-04-13-84182-Gitlab-Runner-\351\205\215\347\275\256.markdown" +++ "b/source/_posts/2021-04-13-84182-Gitlab-Runner-\351\205\215\347\275\256.markdown" @@ -20,7 +20,7 @@ tags: ["git"] docker run --rm -it -v $PWD/tmp/gitlab-runner-config:/etc/gitlab-runner gitlab/gitlab-runner:alpine register --non-interactive \ --url "https://gitlab.com/" \ - --registration-token "PROJECT_REGISTRATION_TOKEN" \ + --token "PROJECT_REGISTRATION_TOKEN" \ --executor "docker" \ --docker-image alpine:latest \ --docker-volumes /var/run/docker.sock:/var/run/docker.sock diff --git "a/source/_posts/2023-10-14-84184-Bitbucket-Runner-\351\205\215\347\275\256.markdown" "b/source/_posts/2023-10-14-84184-Bitbucket-Runner-\351\205\215\347\275\256.markdown" new file mode 100644 index 00000000..89126e67 --- /dev/null +++ "b/source/_posts/2023-10-14-84184-Bitbucket-Runner-\351\205\215\347\275\256.markdown" @@ -0,0 +1,55 @@ +--- +layout: post +title: Bitbucket Runner 配置 +comments: true +post_id: 84184 +permalink: /archives/.html +date: 2023-10-14 20:45:42 +categories: +tags: ["git"] +--- + + +以前有介绍过 Github Runner 和 Gitlab Runner 的配置,现在再来介绍一下 Bitbucket Runner 的配置。 + +参考官方文档: https://support.atlassian.com/bitbucket-cloud/docs/runners/ + +## 添加 Runner +首先禁用 Linux 系统的 swap 功能。若不禁用 swap,在 runner 进行 builder 时会使用 swap 内存,可能会出现内存不足的错误。 + +``` +sudo swapoff -sv +``` + +编辑 `/etc/sysctl.conf` 添加 `vm.swappiness = 1` 再重启系统。 + +接着在 Bitbucket 的设置界面添加 Runner,然后执行界面给出的命令。 +然后在目标机器上执行命令: + +``` +docker run-it -d \ + --name bitbucket-runner \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -e ACCOUNT_UUID= \ + -e REPOSITORY_UUID= \ + -e RUNNER_UUID= \ + -e OAUTH_CLIENT_ID= \ + -e OAUTH_CLIENT_SECRET= \ + wusuopu/bitbucket-pipelines-runner:1.512 +``` + + +## 使用 Runner +在 `bitbucket.pipelines.yml` 中的相关步骤配置 `runs-on`,如: +``` +pipelines: + default: + - step: + runs-on: + - self.hosted + - linux.shell + script: +``` + +因为 runner 是以 linux-shell 的方式运行的,所以会有一些限制: https://support.atlassian.com/bitbucket-cloud/docs/set-up-runners-for-linux-shell/ +