From e721415e4f30614511ead83ae3fd71fa153ee95f Mon Sep 17 00:00:00 2001 From: Peter Zaoral Date: Thu, 19 Feb 2026 12:40:53 +0100 Subject: [PATCH] Allow specifying Java version for remote Maven execution Closes #46321 Signed-off-by: Peter Zaoral --- .../keycloak_remote_installer/defaults/main.yml | 4 +++- .../keycloak_remote_installer/tasks/install.yml | 14 ++++++++------ .../ansible/roles/mvn_remote_runner/tasks/run.yml | 8 ++++++++ .github/workflows/ci.yml | 8 ++++++-- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/scripts/ansible/roles/keycloak_remote_installer/defaults/main.yml b/.github/scripts/ansible/roles/keycloak_remote_installer/defaults/main.yml index 506d551c84b..2e2edfcb058 100644 --- a/.github/scripts/ansible/roles/keycloak_remote_installer/defaults/main.yml +++ b/.github/scripts/ansible/roles/keycloak_remote_installer/defaults/main.yml @@ -3,4 +3,6 @@ kc_home: /opt/keycloak m2_home: ~/.m2 update_system_packages: no install_java: yes -java_version: 25 +java_version: + - 25 + - 21 # TODO: Remove once Keycloak 24 is no longer used for migration tests diff --git a/.github/scripts/ansible/roles/keycloak_remote_installer/tasks/install.yml b/.github/scripts/ansible/roles/keycloak_remote_installer/tasks/install.yml index 3b9380972d1..2270c7365f2 100644 --- a/.github/scripts/ansible/roles/keycloak_remote_installer/tasks/install.yml +++ b/.github/scripts/ansible/roles/keycloak_remote_installer/tasks/install.yml @@ -10,25 +10,27 @@ update_cache: yes -- name: Install Java {{ java_version }} packages on Ubuntu/Debian +- name: Install Java {{ item }} packages on Ubuntu/Debian when: - install_java - ansible_os_family == 'Debian' package: name: - - "openjdk-{{ java_version }}-jdk" - - "openjdk-{{ java_version }}-jre" + - "openjdk-{{ item }}-jdk" + - "openjdk-{{ item }}-jre" state: present + loop: "{{ [java_version] | flatten }}" -- name: Install Java {{ java_version }} packages on RedHat/Amazon +- name: Install Java {{ item }} packages on RedHat/Amazon when: - install_java - ansible_os_family != 'Debian' package: name: - - "java-{{ java_version }}-openjdk" - - "java-{{ java_version }}-openjdk-devel" + - "java-{{ item }}-openjdk" + - "java-{{ item }}-openjdk-devel" state: present + loop: "{{ [java_version] | flatten }}" - name: Install dependencies on the remote hosts package: name={{item}} state=present diff --git a/.github/scripts/ansible/roles/mvn_remote_runner/tasks/run.yml b/.github/scripts/ansible/roles/mvn_remote_runner/tasks/run.yml index c673218de9f..d19e4e673e7 100644 --- a/.github/scripts/ansible/roles/mvn_remote_runner/tasks/run.yml +++ b/.github/scripts/ansible/roles/mvn_remote_runner/tasks/run.yml @@ -16,6 +16,14 @@ ansible.builtin.shell: | set -o pipefail cd {{ kc_home }} + {% if lookup('env', 'JAVA_VERSION') != "" %} + {% if ansible_os_family == 'Debian' %} + export JAVA_HOME=/usr/lib/jvm/java-{{ lookup('env', 'JAVA_VERSION') }}-openjdk-amd64 + {% else %} + export JAVA_HOME=/usr/lib/jvm/java-{{ lookup('env', 'JAVA_VERSION') }}-openjdk + {% endif %} + echo "Using JAVA_HOME: ${JAVA_HOME}" + {% endif %} echo "{{ mvn_params }}" ./mvnw {{ mvn_params }} args: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 824cd8e182b..44cfc097345 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -515,6 +515,7 @@ jobs: id: aurora-migration-tests env: old-version: 24.0.4 + JAVA_VERSION: 21 # Keycloak 24 is not compatible with Java 25+ run: | EC2_CLUSTER_NAME=${{ steps.ec2-create.outputs.ec2_cluster }} AWS_REGION=${{ steps.aurora-init.outputs.region }} @@ -723,10 +724,11 @@ jobs: id: azure-migration-build env: old-version: 24.0.4 + JAVA_VERSION: 21 # Keycloak 24 is not compatible with Java 25+ run: | AZ_VM_CLUSTER_NAME=${{ steps.vm-create.outputs.az_vm_cluster }} AZURE_REGION=${{ steps.azure-init.outputs.region }} - + cd .github/scripts/ansible ./mvn_remote_runner.sh ${AZURE_REGION} ${AZ_VM_CLUSTER_NAME} 'clean install -B -DskipTests -pl testsuite/integration-arquillian/servers/migration -Pauth-server-migration -Dmigrated.auth.server.version=${{ env.old-version }} -Dmaven.build.cache.enabled=true -Pdb-mssql-azure -Dkeycloak.connectionsJpa.user=${{ steps.azure-create.outputs.username }} -Dkeycloak.connectionsJpa.password="${{ env.AZURE_DB_PASSWORD }}" -Dkeycloak.connectionsJpa.database=${{ steps.azure-create.outputs.db }} -Dkeycloak.connectionsJpa.url="jdbc:sqlserver://${{ steps.azure-create.outputs.endpoint }}:1433;databaseName=${{ steps.azure-create.outputs.db }};encrypt=true;trustServerCertificate=false;sendStringParametersAsUnicode=false" -Djdbc.driver.tmp.dir=target/unpacked/keycloak-${{ env.old-version }}/providers' @@ -734,6 +736,7 @@ jobs: id: azure-migration-tests env: old-version: 24.0.4 + JAVA_VERSION: 21 # Keycloak 24 is not compatible with Java 25+ run: | AZ_VM_CLUSTER_NAME=${{ steps.vm-create.outputs.az_vm_cluster }} AZURE_REGION=${{ steps.azure-init.outputs.region }} @@ -749,10 +752,11 @@ jobs: id: azure-integration-build env: old-version: 24.0.4 + JAVA_VERSION: 21 # Keycloak 24 is not compatible with Java 25+ run: | AZ_VM_CLUSTER_NAME=${{ steps.vm-create.outputs.az_vm_cluster }} AZURE_REGION=${{ steps.azure-init.outputs.region }} - + cd .github/scripts/ansible ./mvn_remote_runner.sh ${AZURE_REGION} ${AZ_VM_CLUSTER_NAME} 'clean install -B -DskipTests -pl testsuite/integration-arquillian/servers/migration -Pauth-server-migration -Dmigrated.auth.server.version=${{ env.old-version }} -Dmaven.build.cache.enabled=true -Pdb-mssql-azure -Dkeycloak.connectionsJpa.user=${{ steps.azure-create.outputs.username }} -Dkeycloak.connectionsJpa.password="${{ env.AZURE_DB_PASSWORD }}" -Dkeycloak.connectionsJpa.database=${{ steps.azure-create.outputs.db }} -Dkeycloak.connectionsJpa.url="jdbc:sqlserver://${{ steps.azure-create.outputs.endpoint }}:1433;databaseName=${{ steps.azure-create.outputs.db }};encrypt=true;trustServerCertificate=false;sendStringParametersAsUnicode=false" -Djdbc.driver.tmp.dir=target/unpacked/keycloak-${{ env.old-version }}/providers'