Build gerrit images with bazelisk
We need to use bazelisk to build gerrit so that we can properly track bazel versions in the job. Use the roles developed for gerrit-review to do that, then simplify the dockerfile to have it simply copy the war into the target image. Also add polymer-bridges. Depends-On: https://review.opendev.org/709256 Change-Id: I7c13df51d3b8c117bcc9aab9caad59687471d622
This commit is contained in:
parent
30297fb10d
commit
a8e1d1496d
13
.zuul.yaml
13
.zuul.yaml
@ -200,6 +200,7 @@
|
|||||||
description: Build a gerrit image.
|
description: Build a gerrit image.
|
||||||
parent: system-config-build-image
|
parent: system-config-build-image
|
||||||
pre-run: playbooks/zuul/gerrit/repos.yaml
|
pre-run: playbooks/zuul/gerrit/repos.yaml
|
||||||
|
run: playbooks/zuul/gerrit/run.yaml
|
||||||
required-projects: &gerrit_projects_2_15
|
required-projects: &gerrit_projects_2_15
|
||||||
- name: gerrit.googlesource.com/gerrit
|
- name: gerrit.googlesource.com/gerrit
|
||||||
override-checkout: stable-2.15
|
override-checkout: stable-2.15
|
||||||
@ -239,6 +240,7 @@
|
|||||||
description: Build and upload a gerrit image.
|
description: Build and upload a gerrit image.
|
||||||
parent: system-config-upload-image
|
parent: system-config-upload-image
|
||||||
pre-run: playbooks/zuul/gerrit/repos.yaml
|
pre-run: playbooks/zuul/gerrit/repos.yaml
|
||||||
|
run: playbooks/zuul/gerrit/run.yaml
|
||||||
required-projects: *gerrit_projects_2_15
|
required-projects: *gerrit_projects_2_15
|
||||||
vars: *gerrit_vars_2_15
|
vars: *gerrit_vars_2_15
|
||||||
files: *gerrit_files_2_15
|
files: *gerrit_files_2_15
|
||||||
@ -256,6 +258,7 @@
|
|||||||
description: Build a gerrit image.
|
description: Build a gerrit image.
|
||||||
parent: system-config-build-image
|
parent: system-config-build-image
|
||||||
pre-run: playbooks/zuul/gerrit/repos.yaml
|
pre-run: playbooks/zuul/gerrit/repos.yaml
|
||||||
|
run: playbooks/zuul/gerrit/run.yaml
|
||||||
required-projects: &gerrit_projects_2_16
|
required-projects: &gerrit_projects_2_16
|
||||||
- name: gerrit.googlesource.com/gerrit
|
- name: gerrit.googlesource.com/gerrit
|
||||||
override-checkout: stable-2.16
|
override-checkout: stable-2.16
|
||||||
@ -299,6 +302,7 @@
|
|||||||
description: Build and upload a gerrit image.
|
description: Build and upload a gerrit image.
|
||||||
parent: system-config-upload-image
|
parent: system-config-upload-image
|
||||||
pre-run: playbooks/zuul/gerrit/repos.yaml
|
pre-run: playbooks/zuul/gerrit/repos.yaml
|
||||||
|
run: playbooks/zuul/gerrit/run.yaml
|
||||||
required-projects: *gerrit_projects_2_16
|
required-projects: *gerrit_projects_2_16
|
||||||
vars: *gerrit_vars_2_16
|
vars: *gerrit_vars_2_16
|
||||||
files: *gerrit_files_2_16
|
files: *gerrit_files_2_16
|
||||||
@ -316,6 +320,7 @@
|
|||||||
description: Build a gerrit image.
|
description: Build a gerrit image.
|
||||||
parent: system-config-build-image
|
parent: system-config-build-image
|
||||||
pre-run: playbooks/zuul/gerrit/repos.yaml
|
pre-run: playbooks/zuul/gerrit/repos.yaml
|
||||||
|
run: playbooks/zuul/gerrit/run.yaml
|
||||||
required-projects: &gerrit_projects_3_0
|
required-projects: &gerrit_projects_3_0
|
||||||
- name: gerrit.googlesource.com/gerrit
|
- name: gerrit.googlesource.com/gerrit
|
||||||
override-checkout: stable-3.0
|
override-checkout: stable-3.0
|
||||||
@ -371,6 +376,7 @@
|
|||||||
description: Build and upload a gerrit image.
|
description: Build and upload a gerrit image.
|
||||||
parent: system-config-upload-image
|
parent: system-config-upload-image
|
||||||
pre-run: playbooks/zuul/gerrit/repos.yaml
|
pre-run: playbooks/zuul/gerrit/repos.yaml
|
||||||
|
run: playbooks/zuul/gerrit/run.yaml
|
||||||
required-projects: *gerrit_projects_3_0
|
required-projects: *gerrit_projects_3_0
|
||||||
vars: *gerrit_vars_3_0
|
vars: *gerrit_vars_3_0
|
||||||
files: *gerrit_files_3_0
|
files: *gerrit_files_3_0
|
||||||
@ -392,7 +398,8 @@
|
|||||||
parent: system-config-build-image
|
parent: system-config-build-image
|
||||||
pre-run:
|
pre-run:
|
||||||
- playbooks/zuul/gerrit/repos.yaml
|
- playbooks/zuul/gerrit/repos.yaml
|
||||||
- playbooks/zuul/gerrit/jgit.yaml
|
- playbooks/zuul/gerrit/submodules.yaml
|
||||||
|
run: playbooks/zuul/gerrit/run.yaml
|
||||||
required-projects: &gerrit_projects_master
|
required-projects: &gerrit_projects_master
|
||||||
- opendev/system-config
|
- opendev/system-config
|
||||||
- gerrit.googlesource.com/jgit
|
- gerrit.googlesource.com/jgit
|
||||||
@ -412,6 +419,7 @@
|
|||||||
- gerrit.googlesource.com/plugins/reviewnotes
|
- gerrit.googlesource.com/plugins/reviewnotes
|
||||||
- gerrit.googlesource.com/plugins/singleusergroup
|
- gerrit.googlesource.com/plugins/singleusergroup
|
||||||
- gerrit.googlesource.com/plugins/webhooks
|
- gerrit.googlesource.com/plugins/webhooks
|
||||||
|
- gerrit.googlesource.com/polymer-bridges
|
||||||
vars: &gerrit_vars_master
|
vars: &gerrit_vars_master
|
||||||
zuul_work_dir: src/opendev.org/opendev/system-config
|
zuul_work_dir: src/opendev.org/opendev/system-config
|
||||||
docker_images:
|
docker_images:
|
||||||
@ -447,7 +455,8 @@
|
|||||||
parent: system-config-upload-image
|
parent: system-config-upload-image
|
||||||
pre-run:
|
pre-run:
|
||||||
- playbooks/zuul/gerrit/repos.yaml
|
- playbooks/zuul/gerrit/repos.yaml
|
||||||
- playbooks/zuul/gerrit/jgit.yaml
|
- playbooks/zuul/gerrit/submodules.yaml
|
||||||
|
run: playbooks/zuul/gerrit/run.yaml
|
||||||
required-projects: *gerrit_projects_master
|
required-projects: *gerrit_projects_master
|
||||||
vars: *gerrit_vars_master
|
vars: *gerrit_vars_master
|
||||||
files: *gerrit_files_master
|
files: *gerrit_files_master
|
||||||
|
@ -13,14 +13,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
FROM docker.io/opendevorg/bazel as builder
|
|
||||||
|
|
||||||
USER builder
|
|
||||||
COPY . /usr/src
|
|
||||||
|
|
||||||
ARG BAZEL_OPTS
|
|
||||||
RUN cd /usr/src && bash build-gerrit.sh
|
|
||||||
|
|
||||||
FROM docker.io/opendevorg/gerrit-base
|
FROM docker.io/opendevorg/gerrit-base
|
||||||
|
|
||||||
COPY --from=builder /usr/src/bazel-bin/release.war /var/gerrit/bin/gerrit.war
|
COPY release.war /var/gerrit/bin/gerrit.war
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
- hosts: all
|
|
||||||
tasks:
|
|
||||||
|
|
||||||
- name: Checkout jgit submodule
|
|
||||||
command: "git submodule update --init modules/jgit"
|
|
||||||
args:
|
|
||||||
chdir: /home/zuul/src/gerrit.googlesource.com/gerrit
|
|
@ -1,5 +1,18 @@
|
|||||||
- hosts: all
|
- hosts: all
|
||||||
|
roles:
|
||||||
|
- ensure-java
|
||||||
|
- role: install-nodejs
|
||||||
|
node_version: 10
|
||||||
|
- ensure-bazelisk
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Install essential build packages
|
||||||
|
become: true
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- build-essential
|
||||||
|
- zip
|
||||||
|
- unzip
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: Move plugin repos into gerrit tree
|
- name: Move plugin repos into gerrit tree
|
||||||
command: "mv -f {{ item }} ../gerrit/plugins"
|
command: "mv -f {{ item }} ../gerrit/plugins"
|
||||||
|
9
playbooks/zuul/gerrit/run.yaml
Normal file
9
playbooks/zuul/gerrit/run.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
- hosts: all
|
||||||
|
roles:
|
||||||
|
- role: bazelisk-build
|
||||||
|
zuul_work_dir: /home/zuul/src/gerrit.googlesource.com/gerrit
|
||||||
|
- build-docker-image
|
||||||
|
|
||||||
|
- hosts: localhost
|
||||||
|
roles:
|
||||||
|
- pause-buildset-registry
|
10
playbooks/zuul/gerrit/submodules.yaml
Normal file
10
playbooks/zuul/gerrit/submodules.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
- hosts: all
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: Checkout submodules
|
||||||
|
shell: "[ -d {{ item }} ] && git submodule update --init {{ item }}"
|
||||||
|
args:
|
||||||
|
chdir: /home/zuul/src/gerrit.googlesource.com/gerrit
|
||||||
|
loop:
|
||||||
|
- modules/jgit
|
||||||
|
- polymer-bridges
|
26
roles/bazelisk-build/README.rst
Normal file
26
roles/bazelisk-build/README.rst
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
Run bazelisk build
|
||||||
|
|
||||||
|
Runs bazelisk build with the specified targets.
|
||||||
|
|
||||||
|
**Role Variables**
|
||||||
|
|
||||||
|
.. zuul:rolevar:: bazelisk_targets
|
||||||
|
:default: ""
|
||||||
|
|
||||||
|
The bazelisk targets to build.
|
||||||
|
|
||||||
|
.. zuul:rolevar:: bazelisk_test_targets
|
||||||
|
:default: ""
|
||||||
|
|
||||||
|
The bazelisk targets to test. ``bazelisk test`` will only be run
|
||||||
|
if this value is not the empty string.
|
||||||
|
|
||||||
|
.. zuul:rolevar:: bazelisk_executable
|
||||||
|
:default: bazelisk
|
||||||
|
|
||||||
|
The path to the bazelisk executable.
|
||||||
|
|
||||||
|
.. zuul:rolevar:: zuul_work_dir
|
||||||
|
:default: {{ ansible_user_dir }}/{{ zuul.project.src_dir}}
|
||||||
|
|
||||||
|
The working directory in which to run bazelisk.
|
3
roles/bazelisk-build/defaults/main.yaml
Normal file
3
roles/bazelisk-build/defaults/main.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
bazelisk_targets: release
|
||||||
|
bazelisk_executable: bazelisk
|
||||||
|
zuul_work_dir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir}}"
|
10
roles/bazelisk-build/tasks/main.yaml
Normal file
10
roles/bazelisk-build/tasks/main.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
- name: Run bazelisk build
|
||||||
|
shell: |
|
||||||
|
java -fullversion
|
||||||
|
{{ bazelisk_executable }} version
|
||||||
|
{{ bazelisk_executable }} build --spawn_strategy=standalone --genrule_strategy=standalone {{ bazelisk_targets }}
|
||||||
|
# release.war is a symlink. We want an actual file so that docker copy works right.
|
||||||
|
cp bazel-bin/release.war release.war
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
chdir: "{{ zuul_work_dir }}"
|
Loading…
Reference in New Issue
Block a user