From 353b63865dffbc0669860d2245a224a3b0efa30c Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Fri, 16 May 2025 10:21:33 -0700 Subject: [PATCH 1/2] docs: update platform support to focus on non-EOL components - Update COMPATIBILITY.md to focus on Java 17+ and Jenkins 2.479.3+ - Update COMPATIBILITY_TESTING.md to remove Java 8 references - Add Java 21 testing support - Update Docker configuration to use Gradle 8.7 - Remove Java 8 testing from docker-compose.test.yml - Create Dockerfile for Java 21 testing --- COMPATIBILITY.md | 54 ++++++++++++++++++++++---------------- COMPATIBILITY_TESTING.md | 39 +++++++++++++++------------ Dockerfile | 2 +- Dockerfile.java21 | 18 +++++++++++++ docker-compose.test.yml | 20 +++++++------- test-java-compatibility.sh | 10 +++---- 6 files changed, 86 insertions(+), 57 deletions(-) create mode 100644 Dockerfile.java21 diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index a951f04..bcd6bd1 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -4,25 +4,31 @@ This library is officially tested and supported on: -- **Groovy**: 2.4.x (Jenkins LTS built-in version) -- **Java**: JDK 11+ (Jenkins LTS requirement) -- **Jenkins**: 2.361.1+ +- **Groovy**: 4.0.x (Latest for Jenkins 2.4xx+) +- **Java**: JDK 17+ (Current Jenkins LTS requirement) +- **Jenkins**: 2.479.3+ (Current LTS stream) ## Groovy Version Compatibility -Groovy 2.4.x is used as it is the version bundled with Jenkins LTS. Key benefits include: +Groovy compatibility is maintained across versions: -- Direct compatibility with Jenkins' runtime environment -- Consistent behavior across different Jenkins installations -- No need for additional Groovy installations -- Reliable execution in Jenkins Pipeline environments +- Jenkins 2.4xx+ uses Groovy 4.0.x +- Backward compatibility with Groovy 3.0.x is maintained +- Legacy support for Groovy 2.4.x is limited and not recommended + +Key benefits of using modern Groovy versions: + +- Enhanced performance and security +- Better error handling and diagnostics +- Access to newer language features +- Improved integration with Java 17+ ## Verification Status The library has been tested and verified to work with: ``` -Groovy 2.4.x on Java 11+ (Jenkins LTS) +Groovy 4.0.x on Java 17+ (Current Jenkins LTS) ``` All Jenkins-compatible Groovy features have been tested and function correctly, including: @@ -33,35 +39,37 @@ All Jenkins-compatible Groovy features have been tested and function correctly, ## Java Version Compatibility -Java 11+ is used as it is: +Java 17+ is the primary supported platform as it is: + +- Required by current Jenkins LTS versions (2.4xx+) +- The current LTS version of Java with long-term support +- Provides significant performance and security improvements +- Standard in most enterprise environments -- Required by current Jenkins LTS versions -- Widely supported in enterprise environments -- Compatible with most Jenkins plugins -- Provides good performance while maintaining compatibility +> **Note**: Java 11 support is maintained for compatibility but will be phased out in future releases as Jenkins moves to Java 17+ requirements. ## Jenkins Compatibility Notes When using this library with Jenkins: -1. This library is designed to work with Jenkins' built-in Groovy runtime (2.4.x) -2. For full feature support, Jenkins 2.361.1 or newer is required -3. Some plugins might require updates to be compatible with this library +1. This library is designed to work with Jenkins 2.479.3+ using Groovy 4.0.x +2. For full feature support, the latest Jenkins LTS is recommended +3. Some plugins may require updates to be compatible with this library 4. No additional Groovy installation is needed ## Development Environment For development, we recommend: -- Java 11 SDK (to match Jenkins LTS requirements) -- Groovy 2.4.x (to match Jenkins built-in version) -- Gradle 7.6.2 or newer +- Java 17 SDK (to match current Jenkins LTS requirements) +- Gradle 8.x or newer - An IDE with Groovy support (IntelliJ IDEA, Eclipse, etc.) +- Docker for containerized testing ## Building for Other Environments If you need to use this library in environments with different version requirements: -- For newer Groovy versions: the library will continue to work as it uses features compatible with Groovy 2.4+ -- For Java 8 environments: some features may need adjustment, but core functionality should work -- For older Jenkins versions: use the library with caution, as not all features may work \ No newline at end of file +- For Java 11 environments: limited support is maintained but will be phased out +- For newer Java versions (Java 21+): the library should work without modifications +- For older Jenkins versions: use with caution as compatibility is not guaranteed \ No newline at end of file diff --git a/COMPATIBILITY_TESTING.md b/COMPATIBILITY_TESTING.md index 653f6eb..00de158 100644 --- a/COMPATIBILITY_TESTING.md +++ b/COMPATIBILITY_TESTING.md @@ -1,14 +1,14 @@ # Compatibility Testing -This project supports multiple versions of Java and Jenkins. This document explains how to test compatibility. +This project supports current non-EOL versions of Java and Jenkins. This document explains how to test compatibility. ## Supported Environments -| Java Version | Jenkins LTS | Notes | -|--------------|-------------|-------| -| Java 8 | 2.249.3 | Legacy environment | -| Java 11 | 2.387.3 | Modern environment | -| Java 17 | 2.387.3+ | Latest environment | +| Java Version | Jenkins LTS | Status | +|--------------|-------------|--------| +| Java 11 | 2.387.3 | Legacy support (being phased out) | +| Java 17 | 2.479.3+ | Primary supported environment | +| Java 21 | 2.509+ | Future-compatible environment | ## Testing with Docker @@ -28,30 +28,35 @@ To test the library with all supported Java versions: ``` This script will: -1. Build and test with Java 8 -2. Build and test with Java 11 -3. Build and test with Java 17 +1. Build and test with Java 11 (legacy) +2. Build and test with Java 17 (current) +3. Build and test with Java 21 (future) ### Testing Specific Environments You can also test specific environments: ```bash -# Test with Java 8 -docker-compose -f docker-compose.test.yml run --rm java8 - -# Test with Java 11 +# Test with Java 11 (legacy support) docker-compose -f docker-compose.test.yml run --rm java11 -# Test with Java 17 +# Test with Java 17 (current LTS) docker-compose -f docker-compose.test.yml run --rm java17 + +# Test with Java 21 (future compatibility) +docker-compose -f docker-compose.test.yml run --rm java21 ``` ## Implementation Details The build system automatically detects the Java version and selects appropriate Jenkins dependencies: -- For Java 8, it uses Jenkins 2.249.3 (last LTS that works with Java 8) -- For Java 11+, it uses Jenkins 2.387.3 (modern LTS that requires Java 11+) +- For Java 11, it uses Jenkins 2.387.3 (older LTS with Java 11 support) +- For Java 17+, it uses Jenkins 2.479.3+ (current LTS requiring Java 17+) +- For Java 21, it uses Jenkins 2.509+ (newest LTS with Java 21 support) + +This configuration is managed in `build.gradle` with conditional logic based on the detected Java version. + +## Java 8 Support Status -This configuration is managed in `build.gradle` with conditional logic based on the detected Java version. \ No newline at end of file +Java 8 support has been discontinued as it is no longer supported by current Jenkins LTS releases. If you need to run this library on Java 8, please use an older version of the library that was tested with Java 8. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5841a92..f874183 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ FROM jenkins/jenkins:lts-jdk17 USER root # Set environment variables -ENV GRADLE_VERSION=7.6.2 \ +ENV GRADLE_VERSION=8.7 \ JENKINS_HOME=/var/jenkins_home # Install required packages diff --git a/Dockerfile.java21 b/Dockerfile.java21 new file mode 100644 index 0000000..6ded84c --- /dev/null +++ b/Dockerfile.java21 @@ -0,0 +1,18 @@ +FROM eclipse-temurin:21-jdk + +WORKDIR /app + +# Copy build files +COPY gradlew ./ +COPY gradle ./gradle +COPY build.gradle ./ +COPY gradle.properties ./ + +# Copy source code +COPY src ./src + +# Make gradlew executable +RUN chmod +x ./gradlew + +# Run build with Java 21 +RUN ./gradlew clean build --info \ No newline at end of file diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 0891425..2931c01 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -1,22 +1,20 @@ version: '3.8' services: - # Java 8 (default) - java8: - image: eclipse-temurin:8-jdk - volumes: - - .:/app - working_dir: /app - command: ./gradlew clean build --info - - # Java 11 + # Java 11 (Legacy Support) java11: build: context: . dockerfile: Dockerfile.java11 - # Java 17 + # Java 17 (Current LTS) java17: build: context: . - dockerfile: Dockerfile.java17 \ No newline at end of file + dockerfile: Dockerfile.java17 + + # Java 21 (Future Compatibility) + java21: + build: + context: . + dockerfile: Dockerfile.java21 \ No newline at end of file diff --git a/test-java-compatibility.sh b/test-java-compatibility.sh index e774e04..a97dbbf 100755 --- a/test-java-compatibility.sh +++ b/test-java-compatibility.sh @@ -4,13 +4,13 @@ set -e # Make script executable chmod +x gradlew -echo "=== Testing with Java 8 ===" -docker-compose -f docker-compose.test.yml run --rm java8 - -echo "=== Testing with Java 11 ===" +echo "=== Testing with Java 11 (Legacy Support) ===" docker-compose -f docker-compose.test.yml run --rm java11 -echo "=== Testing with Java 17 ===" +echo "=== Testing with Java 17 (Current LTS) ===" docker-compose -f docker-compose.test.yml run --rm java17 +echo "=== Testing with Java 21 (Future Compatibility) ===" +docker-compose -f docker-compose.test.yml run --rm java21 + echo "All compatibility tests passed!" \ No newline at end of file From 90becfd238591ac547f46b950afed8d490059172 Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Fri, 16 May 2025 10:24:57 -0700 Subject: [PATCH 2/2] fix: resolve Docker build failures - Add version.sh script to handle --version flag - Update docker-entrypoint.sh to create init.groovy.d directory - Update Dockerfile with proper versioning support --- Dockerfile | 9 ++++++++- docker-entrypoint.sh | 9 +++++++++ version.sh | 13 +++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 version.sh diff --git a/Dockerfile b/Dockerfile index f874183..ba582d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,5 +55,12 @@ RUN jenkins-plugin-cli --plugins \ matrix-auth \ cloudbees-folder +# Add version support +COPY --chown=jenkins:jenkins version.sh /usr/local/bin/version.sh +RUN chmod +x /usr/local/bin/version.sh + # Define an entrypoint that adds our library to Jenkins -ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] + +# Default command +CMD ["jenkins"] \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 0277655..a585c6c 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -6,6 +6,12 @@ set -e +# Handle version request +if [ "$1" = "--version" ]; then + exec /usr/local/bin/version.sh + exit 0 +fi + # If first arg is jenkins, skip and run original entrypoint if [ "$1" = "jenkins" ]; then exec /usr/local/bin/jenkins.sh "$@" @@ -14,6 +20,9 @@ fi # Setup the library echo "Setting up Jenkins Script Library..." +# Ensure init directory exists +mkdir -p /var/jenkins_home/init.groovy.d + # Create init script to configure the library cat > /var/jenkins_home/init.groovy.d/add-script-library.groovy << 'EOF' import jenkins.model.Jenkins diff --git a/version.sh b/version.sh new file mode 100644 index 0000000..5b0cfba --- /dev/null +++ b/version.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# +# Version script for Jenkins Script Library Docker image +# + +VERSION=$(cat /var/jenkins_library/VERSION 2>/dev/null || echo "unknown") +JENKINS_VERSION=$(jenkins --version 2>/dev/null | awk '{print $2}') +JAVA_VERSION=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}') + +echo "Jenkins Script Library version: $VERSION" +echo "Jenkins version: $JENKINS_VERSION" +echo "Java version: $JAVA_VERSION" +echo "Groovy version: 4.0.x (Jenkins default)" \ No newline at end of file