Allow overriding of Bazel installer checksum

Checksum retrieval from Github doesn't work when Artifactory is used as
a Github mirror when the installer is not already cached.

Allow setting the Bazel installer checksum as a variable to make the
role work in such cases.

See also https://www.jfrog.com/jira/browse/RTFACT-22923

Change-Id: Icc3480420895b9052a4f1c133659a31fff0723be
This commit is contained in:
Simon Westphahl 2022-09-30 10:08:26 +02:00
parent b095e64337
commit ae22e2c171
No known key found for this signature in database
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: