Skip to content

Commit e647b6c

Browse files
Use container labels to get container ID on GitLab (#126)
1 parent cc641d4 commit e647b6c

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

docs/running-clusterfuzzlite/gitlab.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ To get the most of this page, you should have already set up your
1919
[high-level document on running ClusterFuzzLite].
2020

2121
The following documentation is primarily meant for Gitlab.com with the use of shared runners.
22-
It works also for self-managed Gitlab instances.
22+
It works also for self-managed GitLab instances.
2323

2424
## .gitlab-ci.yml
2525
For basic ClusterFuzzLite functionality, all you need is a single job
@@ -36,24 +36,24 @@ To enable more features, we recommend having different jobs for:
3636
To add a fuzzing job that fuzzes all merge requests to your repo, add the
3737
following default configurations to `.gitlab-ci.yml`:
3838

39-
For self-managed Gitlab instances, this configuration requires at least GitLab 13.3 to be run.
40-
With older versions, the `parallel` keywords does not exist, but you can define `SANITIZER` as a Gitlab CI variable.
39+
For self-managed GitLab instances, this configuration requires at least GitLab 13.3 to be run.
40+
With older versions, the `parallel` keywords does not exist, but you can define `SANITIZER` as a GitLab CI variable.
4141

4242
{% raw %}
4343
```yaml
4444
variables:
4545
SANITIZER: address
4646
CFL_PLATFORM: gitlab
47-
DOCKER_HOST: "tcp://docker:2375" # may be removed in self-managed Gitlab instances
48-
DOCKER_IN_DOCKER: "true" # may be removed in self-managed Gitlab instances
47+
DOCKER_HOST: "tcp://docker:2375" # may be removed in self-managed GitLab instances
48+
DOCKER_IN_DOCKER: "true" # may be removed in self-managed GitLab instances
4949

5050

5151
clusterfuzzlite:
5252
image:
5353
name: gcr.io/oss-fuzz-base/clusterfuzzlite-run-fuzzers:v1
5454
entrypoint: [""]
5555
services:
56-
- docker:dind # may be removed in self-managed Gitlab instances
56+
- docker:dind # may be removed in self-managed GitLab instances
5757

5858
stage: test
5959
parallel:
@@ -65,8 +65,8 @@ clusterfuzzlite:
6565
variables:
6666
MODE: "code-change"
6767
before_script:
68-
# Get gitlab's container id.
69-
- export CFL_CONTAINER_ID=`cut -c9- < /proc/1/cpuset`
68+
# Get GitLab's container id.
69+
- export CFL_CONTAINER_ID=`docker ps -q -f "label=com.gitlab.gitlab-runner.job.id=$CI_JOB_ID" -f "label=com.gitlab.gitlab-runner.type=build"`
7070
script:
7171
# Will build and run the fuzzers.
7272
- python3 "/opt/oss-fuzz/infra/cifuzz/cifuzz_combined_entrypoint.py"
@@ -78,7 +78,7 @@ clusterfuzzlite:
7878
```
7979
{% endraw %}
8080
81-
For self-managed Gitlab instances, you may also wish to set [tags](https://docs.gitlab.com/runner/#tags)
81+
For self-managed GitLab instances, you may also wish to set [tags](https://docs.gitlab.com/runner/#tags)
8282
to select a relevant runner.
8383
8484
Optionally, edit the following variables to customize your settings:
@@ -106,13 +106,13 @@ clusterfuzzlite-corpus:
106106
name: gcr.io/oss-fuzz-base/clusterfuzzlite-run-fuzzers:v1
107107
entrypoint: [""]
108108
services:
109-
- docker:dind # may be removed in self-managed Gitlab instances
109+
- docker:dind # may be removed in self-managed GitLab instances
110110
stage: test
111111
rules:
112112
- if: $MODE == "prune"
113113
- if: $MODE == "batch"
114114
before_script:
115-
- export CFL_CONTAINER_ID=`cut -c9- < /proc/1/cpuset`
115+
- export CFL_CONTAINER_ID=`docker ps -q -f "label=com.gitlab.gitlab-runner.job.id=$CI_JOB_ID" -f "label=com.gitlab.gitlab-runner.type=build"`
116116
script:
117117
- python3 "/opt/oss-fuzz/infra/cifuzz/cifuzz_combined_entrypoint.py"
118118
artifacts:
@@ -151,7 +151,7 @@ clusterfuzzlite-build:
151151
name: gcr.io/oss-fuzz-base/clusterfuzzlite-run-fuzzers:v1
152152
entrypoint: [""]
153153
services:
154-
- docker:dind # may be removed in self-managed Gitlab instances
154+
- docker:dind # may be removed in self-managed GitLab instances
155155
stage: test
156156
rules:
157157
# Use $CI_DEFAULT_BRANCH or $CFL_BRANCH.
@@ -160,7 +160,7 @@ clusterfuzzlite-build:
160160
MODE: "code-change"
161161
UPLOAD_BUILD: "true"
162162
before_script:
163-
- export CFL_CONTAINER_ID=`cut -c9- < /proc/1/cpuset`
163+
- export CFL_CONTAINER_ID=`docker ps -q -f "label=com.gitlab.gitlab-runner.job.id=$CI_JOB_ID" -f "label=com.gitlab.gitlab-runner.type=build"`
164164
script:
165165
- python3 "/opt/oss-fuzz/infra/cifuzz/cifuzz_combined_entrypoint.py"
166166
artifacts:
@@ -182,7 +182,7 @@ clusterfuzzlite-coverage:
182182
name: gcr.io/oss-fuzz-base/clusterfuzzlite-run-fuzzers:v1
183183
entrypoint: [""]
184184
services:
185-
- docker:dind # may be removed in self-managed Gitlab instances
185+
- docker:dind # may be removed in self-managed GitLab instances
186186
stage: test
187187
variables:
188188
SANITIZER: "coverage"
@@ -205,7 +205,7 @@ This schedule should target the main/default/`CFL_BRANCH` branch.
205205

206206
## Extra configuration
207207

208-
### Gitlab runners on self-managed Gitlab instances
208+
### GitLab runners on self-managed GitLab instances
209209

210210
The previous examples used [Docker in docker](https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-in-docker)
211211

@@ -217,11 +217,11 @@ To do so, if you have such a runner ready, you simply need to remove the followi
217217
{% raw %}
218218
```yaml
219219
variables:
220-
DOCKER_HOST: "tcp://docker:2375" # may be removed in self-managed Gitlab instances
221-
DOCKER_IN_DOCKER: "true" # may be removed in self-managed Gitlab instances
220+
DOCKER_HOST: "tcp://docker:2375" # may be removed in self-managed GitLab instances
221+
DOCKER_IN_DOCKER: "true" # may be removed in self-managed GitLab instances
222222
223223
services:
224-
- docker:dind # may be removed in self-managed Gitlab instances
224+
- docker:dind # may be removed in self-managed GitLab instances
225225
```
226226

227227
Note that it should be possible to achieve the same functionality using a shell
@@ -231,7 +231,7 @@ call the `docker` commands on ClusterFuzzLite images.
231231

232232
### Gitlab filestore
233233

234-
You can use the variable `FILESTORE: gitlab` to use Gitlab artifacts for storing
234+
You can use the variable `FILESTORE: gitlab` to use GitLab artifacts for storing
235235
- coverage reports
236236
- corpus
237237
- continuous build
@@ -260,7 +260,7 @@ You need to create a project access token for this repository, with
260260
`read_repository` and `write_repository` rights.
261261

262262
You can also use a personal access token if you do not have access to
263-
project access token, due to your Gitlab license.
263+
project access token, due to your GitLab license.
264264

265265
![gitlab-project-token]
266266

0 commit comments

Comments
 (0)