From 907683299938e0ecdd0155ad33cb273ce3de9c0e Mon Sep 17 00:00:00 2001 From: Haroon Khel Date: Wed, 9 Oct 2024 16:09:43 +0100 Subject: [PATCH 1/6] unixPb: Remove hyphen from Bootjdk symlinks --- ansible/docker/Dockerfile.Alpine3 | 6 +++--- ansible/docker/Dockerfile.CentOS6 | 10 +++++----- ansible/docker/Dockerfile.CentOS7 | 10 +++++----- ansible/docker/Dockerfile.Ubuntu1604 | 10 +++++----- ansible/docker/Dockerfile.Ubuntu2004-riscv64 | 10 +++++----- ansible/docker/Dockerfile.Ubuntu2204 | 10 +++++----- .../roles/adoptopenjdk_install/tasks/main.yml | 4 ++-- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/ansible/docker/Dockerfile.Alpine3 b/ansible/docker/Dockerfile.Alpine3 index fa5ab579e9..cb9f235aad 100644 --- a/ansible/docker/Dockerfile.Alpine3 +++ b/ansible/docker/Dockerfile.Alpine3 @@ -18,12 +18,12 @@ RUN set -eux; \ ENV \ JDK7_BOOT_DIR="/usr/lib/jvm/jdk8" \ JDK8_BOOT_DIR="/usr/lib/jvm/jdk8" \ - JDK10_BOOT_DIR="/usr/lib/jvm/jdk-11" \ - JDK11_BOOT_DIR="/usr/lib/jvm/jdk-11" \ + JDK10_BOOT_DIR="/usr/lib/jvm/jdk11" \ + JDK11_BOOT_DIR="/usr/lib/jvm/jdk11" \ JDK14_BOOT_DIR="/usr/lib/jvm/zulu14" \ JDK15_BOOT_DIR="/usr/lib/jvm/zulu15" \ JDK16_BOOT_DIR="/usr/lib/jvm/zulu16" \ - JDK17_BOOT_DIR="/usr/lib/jvm/jdk-17" \ + JDK17_BOOT_DIR="/usr/lib/jvm/jdk17" \ JDK18_BOOT_DIR="/usr/lib/jvm/zulu18" \ JDKLATEST_BOOT_DIR="/usr/lib/jvm/zulu18" \ JAVA_HOME="/usr/lib/jvm/jdk8" diff --git a/ansible/docker/Dockerfile.CentOS6 b/ansible/docker/Dockerfile.CentOS6 index 49f2274cde..73b87b09d8 100644 --- a/ansible/docker/Dockerfile.CentOS6 +++ b/ansible/docker/Dockerfile.CentOS6 @@ -27,9 +27,9 @@ RUN useradd -c "Jenkins user" -d /home/${user} -u 1000 -g 1000 -m ${user} ENV \ JDK7_BOOT_DIR="/usr/lib/jvm/java-1.7.0-openjdk.x86_64" \ JDK8_BOOT_DIR="/usr/lib/jvm/java-1.8.0-openjdk.x86_64" \ - JDK10_BOOT_DIR="/usr/lib/jvm/jdk-10" \ - JDK11_BOOT_DIR="/usr/lib/jvm/jdk-11" \ - JDK13_BOOT_DIR="/usr/lib/jvm/jdk-13" \ - JDK14_BOOT_DIR="/usr/lib/jvm/jdk-14" \ - JDKLATEST_BOOT_DIR="/usr/lib/jvm/jdk-14" \ + JDK10_BOOT_DIR="/usr/lib/jvm/jdk10" \ + JDK11_BOOT_DIR="/usr/lib/jvm/jdk11" \ + JDK13_BOOT_DIR="/usr/lib/jvm/jdk13" \ + JDK14_BOOT_DIR="/usr/lib/jvm/jdk14" \ + JDKLATEST_BOOT_DIR="/usr/lib/jvm/jdk14" \ JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk.x86_64" diff --git a/ansible/docker/Dockerfile.CentOS7 b/ansible/docker/Dockerfile.CentOS7 index 5f430918c6..c6c684d6b5 100644 --- a/ansible/docker/Dockerfile.CentOS7 +++ b/ansible/docker/Dockerfile.CentOS7 @@ -33,9 +33,9 @@ RUN useradd -c "Jenkins user" -d /home/${user} -u 1000 -g 1000 -m ${user} ENV \ JDK7_BOOT_DIR="/usr/lib/jvm/java-1.7.0-openjdk" \ JDK8_BOOT_DIR="/usr/lib/jvm/java-1.8.0-openjdk" \ - JDK10_BOOT_DIR="/usr/lib/jvm/jdk-10" \ - JDK11_BOOT_DIR="/usr/lib/jvm/jdk-11" \ - JDK13_BOOT_DIR="/usr/lib/jvm/jdk-13" \ - JDK14_BOOT_DIR="/usr/lib/jvm/jdk-14" \ - JDKLATEST_BOOT_DIR="/usr/lib/jvm/jdk-14" \ + JDK10_BOOT_DIR="/usr/lib/jvm/jdk10" \ + JDK11_BOOT_DIR="/usr/lib/jvm/jdk11" \ + JDK13_BOOT_DIR="/usr/lib/jvm/jdk13" \ + JDK14_BOOT_DIR="/usr/lib/jvm/jdk14" \ + JDKLATEST_BOOT_DIR="/usr/lib/jvm/jdk14" \ JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk" diff --git a/ansible/docker/Dockerfile.Ubuntu1604 b/ansible/docker/Dockerfile.Ubuntu1604 index 0a299053d1..a2a2a7f6a5 100644 --- a/ansible/docker/Dockerfile.Ubuntu1604 +++ b/ansible/docker/Dockerfile.Ubuntu1604 @@ -33,9 +33,9 @@ RUN mv /bin/uname /bin/uname.real && echo "/bin/uname.real \$@ | sed 's/aarch64/ ENV \ JDK7_BOOT_DIR="/usr/lib/jvm/jdk8" \ JDK8_BOOT_DIR="/usr/lib/jvm/jdk8" \ - JDK10_BOOT_DIR="/usr/lib/jvm/jdk-10" \ - JDK11_BOOT_DIR="/usr/lib/jvm/jdk-11" \ - JDK13_BOOT_DIR="/usr/lib/jvm/jdk-13" \ - JDK14_BOOT_DIR="/usr/lib/jvm/jdk-14" \ - JDKLATEST_BOOT_DIR="/usr/lib/jvm/jdk-14" \ + JDK10_BOOT_DIR="/usr/lib/jvm/jdk10" \ + JDK11_BOOT_DIR="/usr/lib/jvm/jdk11" \ + JDK13_BOOT_DIR="/usr/lib/jvm/jdk13" \ + JDK14_BOOT_DIR="/usr/lib/jvm/jdk14" \ + JDKLATEST_BOOT_DIR="/usr/lib/jvm/jdk14" \ JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk" diff --git a/ansible/docker/Dockerfile.Ubuntu2004-riscv64 b/ansible/docker/Dockerfile.Ubuntu2004-riscv64 index 72d9c3665d..21d7aff700 100644 --- a/ansible/docker/Dockerfile.Ubuntu2004-riscv64 +++ b/ansible/docker/Dockerfile.Ubuntu2004-riscv64 @@ -20,8 +20,8 @@ RUN groupadd -g 1000 ${user} RUN useradd -c "Jenkins user" -d /home/${user} -u 1000 -g 1000 -m ${user} ENV \ - JDK11_BOOT_DIR="/usr/lib/jvm/jdk-11" \ - JDK17_BOOT_DIR="/usr/lib/jvm/jdk-17" \ - JDK19_BOOT_DIR="/usr/lib/jvm/jdk-19" \ - JDK21_BOOT_DIR="/usr/lib/jvm/jdk-21" \ - JAVA_HOME="/usr/lib/jvm/jdk-11" + JDK11_BOOT_DIR="/usr/lib/jvm/jdk11" \ + JDK17_BOOT_DIR="/usr/lib/jvm/jdk17" \ + JDK19_BOOT_DIR="/usr/lib/jvm/jdk19" \ + JDK21_BOOT_DIR="/usr/lib/jvm/jdk21" \ + JAVA_HOME="/usr/lib/jvm/jdk11" diff --git a/ansible/docker/Dockerfile.Ubuntu2204 b/ansible/docker/Dockerfile.Ubuntu2204 index a256077f70..a7135b1b2d 100644 --- a/ansible/docker/Dockerfile.Ubuntu2204 +++ b/ansible/docker/Dockerfile.Ubuntu2204 @@ -22,9 +22,9 @@ RUN useradd -c "Jenkins user" -d /home/${user} -u 1000 -g 1000 -m ${user} ENV \ JDK7_BOOT_DIR="/usr/lib/jvm/jdk8" \ JDK8_BOOT_DIR="/usr/lib/jvm/jdk8" \ - JDK10_BOOT_DIR="/usr/lib/jvm/jdk-10" \ - JDK11_BOOT_DIR="/usr/lib/jvm/jdk-11" \ - JDK13_BOOT_DIR="/usr/lib/jvm/jdk-13" \ - JDK14_BOOT_DIR="/usr/lib/jvm/jdk-14" \ - JDKLATEST_BOOT_DIR="/usr/lib/jvm/jdk-14" \ + JDK10_BOOT_DIR="/usr/lib/jvm/jdk10" \ + JDK11_BOOT_DIR="/usr/lib/jvm/jdk11" \ + JDK13_BOOT_DIR="/usr/lib/jvm/jdk13" \ + JDK14_BOOT_DIR="/usr/lib/jvm/jdk14" \ + JDKLATEST_BOOT_DIR="/usr/lib/jvm/jdk14" \ JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk" diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml index f4ab2c0791..eecbe213c6 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml @@ -33,7 +33,7 @@ - name: Set path variable when jdk_version != 8 set_fact: - path: /usr/lib/jvm/jdk-{{ jdk_version }} + path: /usr/lib/jvm/jdk{{ jdk_version }} when: - jdk_version != 8 - ansible_distribution != "MacOSX" @@ -41,7 +41,7 @@ - name: Set path variable (macOS) set_fact: - path: "/Library/Java/JavaVirtualMachines/jdk-{{ jdk_version }}" + path: "/Library/Java/JavaVirtualMachines/jdk{{ jdk_version }}" when: ansible_distribution == "MacOSX" tags: adoptopenjdk_install From 8effd9722d44811d1effb86be2b5c7add4c495a6 Mon Sep 17 00:00:00 2001 From: Haroon Khel Date: Fri, 11 Oct 2024 13:38:14 +0100 Subject: [PATCH 2/6] remove hyphen from windows bootjdk symlinks --- .../roles/Java8/tasks/main.yml | 10 +++++----- .../roles/Java_install/tasks/main.yml | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java8/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java8/tasks/main.yml index e432d54975..d37c8eca51 100644 --- a/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java8/tasks/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java8/tasks/main.yml @@ -4,7 +4,7 @@ ########## - name: Test if Java 8 is already installed win_stat: - path: 'C:\openjdk\jdk-8\bin' + path: 'C:\openjdk\jdk8\bin' register: java8_installed tags: Java8 @@ -29,16 +29,16 @@ tags: Java8 - name: Create symlink to directory without spaces if not already there - win_shell: for /D %a in ("C:\Program Files\Java\jdk8*") do IF NOT EXIST "C:\openjdk\jdk-8" MKLINK /D "C:\openjdk\jdk-8" "%a" + win_shell: for /D %a in ("C:\Program Files\Java\jdk8*") do IF NOT EXIST "C:\openjdk\jdk8" MKLINK /D "C:\openjdk\jdk8" "%a" args: executable: cmd.exe - creates: 'C:\openjdk\jdk-8' + creates: 'C:\openjdk\jdk8' tags: Java8 - name: Set JAVA_HOME to version 8 win_path: name: JAVA_HOME - elements: C:\openjdk\jdk-8 + elements: C:\openjdk\jdk8 scope: machine state: present when: (not java8_installed.stat.exists) @@ -47,7 +47,7 @@ - name: Add JAVA_HOME/bin to Path win_path: name: Path - elements: C:\openjdk\jdk-8\bin + elements: C:\openjdk\jdk8\bin scope: machine state: present when: (not java8_installed.stat.exists) diff --git a/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java_install/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java_install/tasks/main.yml index 6786ce4313..3fde488e36 100644 --- a/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java_install/tasks/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java_install/tasks/main.yml @@ -4,7 +4,7 @@ ################ - name: Test if Java is already installed version {{ jdk_version }} win_stat: - path: 'C:\openjdk\jdk-{{ jdk_version }}\bin' + path: 'C:\openjdk\jdk{{ jdk_version }}\bin' register: java_installed tags: Java_install @@ -39,10 +39,10 @@ tags: Java_install - name: Create symlink to directory without spaces if not already there - win_shell: for /D %a in ("C:\Program Files\Java\jdk-{{ jdk_version }}*") do IF NOT EXIST "C:\openjdk\jdk-{{ jdk_version }}" MKLINK /D "C:\openjdk\jdk-{{ jdk_version }}" "%a" + win_shell: for /D %a in ("C:\Program Files\Java\jdk-{{ jdk_version }}*") do IF NOT EXIST "C:\openjdk\jdk{{ jdk_version }}" MKLINK /D "C:\openjdk\jdk{{ jdk_version }}" "%a" args: executable: cmd.exe - creates: 'C:\openjdk\jdk-{{ jdk_version }}' + creates: 'C:\openjdk\jdk{{ jdk_version }}' tags: Java_install - name: Remove temp zip file From 8e31c2434b3d3ff1e16365f01af64acbf45bf696 Mon Sep 17 00:00:00 2001 From: Haroon Khel Date: Fri, 11 Oct 2024 16:59:30 +0100 Subject: [PATCH 3/6] Use hyphenated path when looking for unzipped binary --- .../roles/adoptopenjdk_install/tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml index eecbe213c6..1e3606fdd7 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml @@ -136,7 +136,7 @@ - not usr_lib_jvm_exists.stat.exists tags: adoptopenjdk_install -- name: Check if jdk-{{ jdk_version }} is already installed in the target location +- name: Check if jdk{{ jdk_version }} is already installed in the target location shell: ls -ld {{ path }} >/dev/null 2>&1 failed_when: false register: adoptopenjdk_installed @@ -356,7 +356,7 @@ until: adoptopenjdk_unpack is not failed - name: Get {{ path }}* full path name - shell: set -o pipefail | ls -ld {{ path }}* 2>/dev/null | awk '{print $9}' + shell: set -o pipefail | ls -ld /usr/lib/jvm/jdk-{{ jdk_version }}* 2>/dev/null | awk '{print $9}' register: adoptopenjdk_dir changed_when: false when: From bfefb6c96ee0cc171907799193809012ae86e115 Mon Sep 17 00:00:00 2001 From: Haroon Khel Date: Tue, 15 Oct 2024 13:16:29 +0100 Subject: [PATCH 4/6] Find the jdk directory using find module --- .../roles/adoptopenjdk_install/tasks/main.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml index 1e3606fdd7..9948cca011 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml @@ -356,17 +356,21 @@ until: adoptopenjdk_unpack is not failed - name: Get {{ path }}* full path name - shell: set -o pipefail | ls -ld /usr/lib/jvm/jdk-{{ jdk_version }}* 2>/dev/null | awk '{print $9}' - register: adoptopenjdk_dir - changed_when: false + find: + paths: /usr/lib/jvm + patterns: + - "^jdk{{ jdk_version }}*" + - "^jdk-{{ jdk_version }}*" + use_regex: yes + file_type: directory when: - ansible_distribution != "MacOSX" - adoptopenjdk_installed.rc != 0 - tags: adoptopenjdk_install + register: adoptopenjdk_dir - name: Create symlink to major version file: - src: '{{ adoptopenjdk_dir.stdout }}' + src: '{{ adoptopenjdk_dir.files[0].path }}' dest: '{{ path }}' state: link when: @@ -376,7 +380,7 @@ - name: Chown {{ path }}* file: - path: '{{ adoptopenjdk_dir.stdout }}' + path: '{{ adoptopenjdk_dir.files[0].path }}' state: directory owner: root recurse: yes From a53fba9741743caa31a7ef9d43a1a8be24b02ae9 Mon Sep 17 00:00:00 2001 From: Haroon Khel Date: Tue, 5 Nov 2024 14:01:07 +0000 Subject: [PATCH 5/6] Update regex for JDK path search --- .../roles/adoptopenjdk_install/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml index 9948cca011..cfc60fb35e 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml @@ -360,7 +360,7 @@ paths: /usr/lib/jvm patterns: - "^jdk{{ jdk_version }}*" - - "^jdk-{{ jdk_version }}*" + - "^jdk-{{ jdk_version }}.*" use_regex: yes file_type: directory when: From b58bb12cc87b0834260085b2126c520a0416eedb Mon Sep 17 00:00:00 2001 From: Haroon Khel Date: Tue, 5 Nov 2024 14:53:44 +0000 Subject: [PATCH 6/6] Revert changes on windows --- .../roles/Java8/tasks/main.yml | 10 +++++----- .../roles/Java_install/tasks/main.yml | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java8/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java8/tasks/main.yml index d37c8eca51..e432d54975 100644 --- a/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java8/tasks/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java8/tasks/main.yml @@ -4,7 +4,7 @@ ########## - name: Test if Java 8 is already installed win_stat: - path: 'C:\openjdk\jdk8\bin' + path: 'C:\openjdk\jdk-8\bin' register: java8_installed tags: Java8 @@ -29,16 +29,16 @@ tags: Java8 - name: Create symlink to directory without spaces if not already there - win_shell: for /D %a in ("C:\Program Files\Java\jdk8*") do IF NOT EXIST "C:\openjdk\jdk8" MKLINK /D "C:\openjdk\jdk8" "%a" + win_shell: for /D %a in ("C:\Program Files\Java\jdk8*") do IF NOT EXIST "C:\openjdk\jdk-8" MKLINK /D "C:\openjdk\jdk-8" "%a" args: executable: cmd.exe - creates: 'C:\openjdk\jdk8' + creates: 'C:\openjdk\jdk-8' tags: Java8 - name: Set JAVA_HOME to version 8 win_path: name: JAVA_HOME - elements: C:\openjdk\jdk8 + elements: C:\openjdk\jdk-8 scope: machine state: present when: (not java8_installed.stat.exists) @@ -47,7 +47,7 @@ - name: Add JAVA_HOME/bin to Path win_path: name: Path - elements: C:\openjdk\jdk8\bin + elements: C:\openjdk\jdk-8\bin scope: machine state: present when: (not java8_installed.stat.exists) diff --git a/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java_install/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java_install/tasks/main.yml index 3fde488e36..6786ce4313 100644 --- a/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java_install/tasks/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Windows_Playbook/roles/Java_install/tasks/main.yml @@ -4,7 +4,7 @@ ################ - name: Test if Java is already installed version {{ jdk_version }} win_stat: - path: 'C:\openjdk\jdk{{ jdk_version }}\bin' + path: 'C:\openjdk\jdk-{{ jdk_version }}\bin' register: java_installed tags: Java_install @@ -39,10 +39,10 @@ tags: Java_install - name: Create symlink to directory without spaces if not already there - win_shell: for /D %a in ("C:\Program Files\Java\jdk-{{ jdk_version }}*") do IF NOT EXIST "C:\openjdk\jdk{{ jdk_version }}" MKLINK /D "C:\openjdk\jdk{{ jdk_version }}" "%a" + win_shell: for /D %a in ("C:\Program Files\Java\jdk-{{ jdk_version }}*") do IF NOT EXIST "C:\openjdk\jdk-{{ jdk_version }}" MKLINK /D "C:\openjdk\jdk-{{ jdk_version }}" "%a" args: executable: cmd.exe - creates: 'C:\openjdk\jdk{{ jdk_version }}' + creates: 'C:\openjdk\jdk-{{ jdk_version }}' tags: Java_install - name: Remove temp zip file