diff --git a/roles/ensure-bazel/README.rst b/roles/ensure-bazel/README.rst index 9cb15e206..67c578cf4 100644 --- a/roles/ensure-bazel/README.rst +++ b/roles/ensure-bazel/README.rst @@ -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. diff --git a/roles/ensure-bazel/defaults/main.yaml b/roles/ensure-bazel/defaults/main.yaml index d47f0b9b6..5fcaf9de0 100644 --- a/roles/ensure-bazel/defaults/main.yaml +++ b/roles/ensure-bazel/defaults/main.yaml @@ -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 diff --git a/roles/ensure-bazel/tasks/install-bazel.yaml b/roles/ensure-bazel/tasks/install-bazel.yaml index 735462052..e814cd407 100644 --- a/roles/ensure-bazel/tasks/install-bazel.yaml +++ b/roles/ensure-bazel/tasks/install-bazel.yaml @@ -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: