Skip to content

Commit

Permalink
Merge pull request #73 from gounthar/gitpodify
Browse files Browse the repository at this point in the history
feat(gitpod): Enhancing Project Accessibility with GitPod Integration
  • Loading branch information
gounthar authored Jul 10, 2024
2 parents 2393c83 + c181777 commit fd8230e
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This .gitpod.yml configuration file is designed for a Java project using Maven. It specifies the Docker image to be used
# and defines initialization tasks to be run when the Gitpod workspace is created.

# Specify the Docker image to be used by Gitpod for the workspace. The Dockerfile is located in the same directory
# and is named `Dockerfile`. This Dockerfile sets up the Java development environment, including JDK 17, Git, and Maven.
image:
file: .gitpod/Dockerfile
# Define tasks to be executed when the workspace is initialized. These tasks are run in the order they are listed.
tasks:
- before: chmod +x .gitpod/init.sh
init: .gitpod/init.sh
# The `before` task ensures that the `init.sh` script has executable permissions. This is crucial for allowing the script to run without permission issues.
# The `init` phase runs a shell script named `init.sh` located in the `.gitpod` directory of the project. This script is responsible
# for performing initial setup tasks such as installing dependencies and setting up the project environment. This ensures
# that the workspace is ready for development as soon as it is launched.
14 changes: 14 additions & 0 deletions .gitpod/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This Dockerfile is designed to set up a Java development environment with JDK 17 and Git,
# specifically tailored for building Jenkins plugins. It includes the installation of Maven,
# cloning of two specific Jenkins plugin repositories, and building these plugins using Maven.

# Start from a base image that includes JDK 17 and Git. This serves as the foundation for the development environment.
FROM gitpod/workspace-java-17

# Update the package list and install Maven. Maven is required for building Java projects, including Jenkins plugins.
# The `apt-get update` command updates the list of available packages and their versions, but it does not install or
# upgrade any packages. The `apt-get install -y maven` command installs Maven without requiring confirmation from the user.
# Finally, `rm -rf /var/lib/apt/lists/*` cleans up the package list files to keep the Docker image size down.
RUN sudo apt-get update && \
sudo apt-get install -y maven && \
sudo rm -rf /var/lib/apt/lists/*
57 changes: 57 additions & 0 deletions .gitpod/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
# This script is designed to set up the environment for a Java project using Maven.
# It performs a clean install of the project dependencies and sets up a directory
# for Jenkins plugin development by cloning necessary repositories.

# Install dependencies and perform initial setup

# Run Maven clean install to ensure all project dependencies are correctly installed
# and the project is built successfully.
mvn clean install

# Create a directory for the test plugins and move into it. This directory will serve
# as a workspace for cloning and building Jenkins plugin repositories.
mkdir -p test-plugins && cd test-plugins || exit

# Clone the first Jenkins plugin repository. The badge-plugin is a Jenkins plugin that
# adds badges to build pages, indicating various conditions like coverage or build status.
# Define the repository URL and the directory name
REPO_URL="https://github.com/jenkinsci/badge-plugin.git"
DIR_NAME="badge-plugin"

# Check if the directory exists and is not empty
if [ -d "$DIR_NAME" ] && [ "$(ls -A $DIR_NAME)" ]; then
echo "The directory $DIR_NAME already exists and is not empty. Skipping clone."
else
# If the directory does not exist or is empty, clone the repository
echo "Cloning $REPO_URL into $DIR_NAME..."
git clone $REPO_URL $DIR_NAME
fi

# Clone the second Jenkins plugin repository. The build-timestamp-plugin adds the ability
# to display build timestamps in the Jenkins UI. This plugin will also be built as part
# of the Docker image setup.
REPO_URL="https://github.com/jenkinsci/build-timestamp-plugin.git"
DIR_NAME="build-timestamp-plugin"

# Check if the directory exists and is not empty
if [ -d "$DIR_NAME" ] && [ "$(ls -A $DIR_NAME)" ]; then
echo "The directory $DIR_NAME already exists and is not empty. Skipping clone."
else
# If the directory does not exist or is empty, clone the repository
echo "Cloning $REPO_URL into $DIR_NAME..."
git clone $REPO_URL $DIR_NAME
fi

# Check if the terminal supports colors
if tput colors > /dev/null 2>&1; then
color_cyan="\033[36m"
color_reset="\033[0m"
else
color_cyan=""
color_reset=""
fi

echo -e "As a gentle reminder, we have already cloned two Jenkins plugin repositories: ${color_cyan}badge-plugin${color_reset} and ${color_cyan}build-timestamp-plugin${color_reset}."
echo -e "You can now proceed with the modernizer tool thanks to the following commands:"
echo -e "${color_cyan}java -jar plugin-modernizer-cli/target/jenkins-plugin-modernizer-999999-SNAPSHOT.jar --plugins badge-plugin,build-timestamp-plugin --recipes AddPluginsBom,AddCodeOwner${color_reset}"

0 comments on commit fd8230e

Please sign in to comment.