Merge "Allow overriding of Bazel installer checksum"

This commit is contained in:
Zuul 2022-10-05 05:44:26 +00:00 committed by Gerrit Code Review
commit 1a166a3bf8
3 changed files with 21 additions and 7 deletions

View File

@ -11,3 +11,9 @@ Download and install Bazel, if the specified version is not already present.
:default: 'https://github.com/bazelbuild/bazel/releases/download'
The base URL to use when downloading Bazel releases.
.. zuul:rolevar:: bazel_installer_checksum
:default: None
The Bazel installer SHA256 checksum. If not provided, the checksum will be
retrieved from Github.

View File

@ -1,4 +1,5 @@
---
bazel_version: '3.1.0'
bazel_release_url: 'https://github.com/bazelbuild/bazel/releases/download'
bazel_installer_checksum:
install_bazel_if_missing: true

View File

@ -3,22 +3,29 @@
state: directory
register: bazel_installer_tempdir
- name: Get installer checksum
uri:
url: "{{ bazel_release_url }}/{{ bazel_version }}/bazel-{{ bazel_version }}-installer-linux-x86_64.sh.sha256"
return_content: true
register: bazel_installer_checksum
- name: Fetch checksum from Github
when: not bazel_installer_checksum
block:
- name: Get installer checksum
uri:
url: "{{ bazel_release_url }}/{{ bazel_version }}/bazel-{{ bazel_version }}-installer-linux-x86_64.sh.sha256"
return_content: true
register: zj_checksum_response
- name: Set installer checksum
set_fact:
bazel_installer_checksum: "{{ zj_checksum_response.content.split(' ')[0] }}"
- name: Display checksum
debug:
msg: "Checksum is {{ bazel_installer_checksum.content.split(' ')[0] }}"
msg: "Checksum is {{ bazel_installer_checksum }}"
- name: Download bazel installer
get_url:
url: "{{ bazel_release_url }}/{{ bazel_version }}/bazel-{{ bazel_version }}-installer-linux-x86_64.sh"
dest: "{{ bazel_installer_tempdir.path }}/bazel-{{ bazel_version }}-installer-linux-x86_64.sh"
mode: 0755
checksum: "sha256:{{ bazel_installer_checksum.content.split(' ')[0] }}"
checksum: "sha256:{{ bazel_installer_checksum }}"
- name: Display distribution
debug: