Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can I use Bazel with pipelines?

Victor A Martinez March 17, 2018

I want to use the  Bazel build tool to create my artifacts on the pipelines. What would be the best way to install and use bazel in the pipelines so I can have cached builds? Has anyone ever got it to work?

2 answers

3 votes
Jenia Varavva July 21, 2020

I got bazel to work in a pipeline and reuse the cached arifacts. Caching the default ~/.cache/bazel directory didn't work for me (complained about corrupt installation on repeated builds), but using --disk_cache flag did. Something like the following:

image:
name: l.gcr.io/google/bazel:3.4.1

pipelines:
default:
- step:
caches:
- bazel
script:
- bazel test --disk_cache=~/.cache/my-bazel //...
definitions:
caches:
bazel: ~/.cache/my-bazel
2 votes
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 28, 2018

Hi Victor,

For running and install Bazel, you can do so similar as in a normal Bash environment. You can also use a Docker image from DockerHub that already has Basel installed. There are currently no official Bazel images, so you will need a community created one.

Documentation on configuring Docker images: https://confluence.atlassian.com/bitbucket/use-docker-images-as-build-environments-792298897.html

For caching, you configure specific directories to be cached. So in this case, you can use cache directories from Bazel.

Bazel provides some documentation on default caches here: https://docs.bazel.build/versions/master/output_directories.html

Pipelines Cache documentation can be found here: https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html

Thanks,

Phil

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events