Allow specifying Java version for remote Maven execution

Closes #46321

Signed-off-by: Peter Zaoral <pzaoral@redhat.com>
This commit is contained in:
Peter Zaoral 2026-02-19 12:40:53 +01:00 committed by GitHub
parent da95f7ec05
commit e721415e4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 9 deletions

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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'