Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
- 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
39 changes: 22 additions & 17 deletions COMPATIBILITY_TESTING.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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.
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.
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

# Default command
CMD ["jenkins"]
18 changes: 18 additions & 0 deletions Dockerfile.java21
Original file line number Diff line number Diff line change
@@ -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
20 changes: 9 additions & 11 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -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
dockerfile: Dockerfile.java17

# Java 21 (Future Compatibility)
java21:
build:
context: .
dockerfile: Dockerfile.java21
9 changes: 9 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test-java-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
13 changes: 13 additions & 0 deletions version.sh
Original file line number Diff line number Diff line change
@@ -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)"
Loading