Skip to content

Commit

Permalink
新文章: 84184
Browse files Browse the repository at this point in the history
  • Loading branch information
wusuopu committed Oct 15, 2023
1 parent 19321ec commit 118d771
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 55 additions & 0 deletions source/_posts/2023-10-14-84184-Bitbucket-Runner-配置.markdown
Original file line number Diff line number Diff line change
@@ -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=<accountUuid> \
-e REPOSITORY_UUID=<repositoryUuid> \
-e RUNNER_UUID=<runnerUuid> \
-e OAUTH_CLIENT_ID=<OAuthClientId> \
-e OAUTH_CLIENT_SECRET=<OAuthClientSecret> \
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/

0 comments on commit 118d771

Please sign in to comment.