.
This commit is contained in:
40
Cloudron/jenkins.knownelement.com/CloudronManifest.json
Normal file
40
Cloudron/jenkins.knownelement.com/CloudronManifest.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"id": "io.jenkins.cloudron",
|
||||
"title": "Jenkins",
|
||||
"author": "Cloudron Packager",
|
||||
"description": "Jenkins is an open source automation server which enables developers to reliably build, test, and deploy their software.",
|
||||
"tagline": "The leading open source automation server",
|
||||
"version": "1.0.0",
|
||||
"healthCheckPath": "/login",
|
||||
"httpPort": 8080,
|
||||
"manifestVersion": 2,
|
||||
"website": "https://jenkins.io/",
|
||||
"contactEmail": "support@cloudron.io",
|
||||
"icon": "file://logo.png",
|
||||
"dockerImage": "cloudron/jenkins",
|
||||
"memoryLimit": 2048000000,
|
||||
"addons": {
|
||||
"localstorage": {
|
||||
"title": "Jenkins Data"
|
||||
}
|
||||
},
|
||||
"optionalAddons": {
|
||||
"ldap": {
|
||||
"title": "LDAP Integration",
|
||||
"description": "Allow users to login with LDAP credentials"
|
||||
},
|
||||
"oauth": {
|
||||
"title": "OAuth Integration",
|
||||
"description": "Allow users to login with Cloudron credentials"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"ci",
|
||||
"cd",
|
||||
"devops",
|
||||
"automation"
|
||||
],
|
||||
"postInstallMessage": "Jenkins is now installed. The initial admin password is shown in the logs. You can view it by running 'cloudron logs -f'. The password is displayed after 'Jenkins initial setup is required.' in the logs.",
|
||||
"minBoxVersion": "5.4.0",
|
||||
"documentationUrl": "https://jenkins.io/doc/"
|
||||
}
|
49
Cloudron/jenkins.knownelement.com/Dockerfile
Normal file
49
Cloudron/jenkins.knownelement.com/Dockerfile
Normal file
@@ -0,0 +1,49 @@
|
||||
FROM cloudron/base:4.2.0
|
||||
|
||||
# Add Jenkins repository key and repository
|
||||
RUN apt-get update && \
|
||||
apt-get install -y gnupg curl software-properties-common && \
|
||||
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | gpg --dearmor -o /usr/share/keyrings/jenkins-keyring.gpg && \
|
||||
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.gpg] https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list
|
||||
|
||||
# Install Jenkins and required dependencies
|
||||
RUN apt-get update && \
|
||||
apt-get install -y openjdk-17-jdk jenkins fontconfig && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install required plugins for Cloudron integration
|
||||
RUN mkdir -p /tmp/data/plugins && \
|
||||
cd /tmp/data/plugins && \
|
||||
curl -L -o ldap.hpi https://updates.jenkins.io/latest/ldap.hpi && \
|
||||
curl -L -o oic-auth.hpi https://updates.jenkins.io/latest/oic-auth.hpi && \
|
||||
curl -L -o configuration-as-code.hpi https://updates.jenkins.io/latest/configuration-as-code.hpi && \
|
||||
curl -L -o credentials.hpi https://updates.jenkins.io/latest/credentials.hpi && \
|
||||
chmod 644 *.hpi
|
||||
|
||||
# Create template for casc.yaml
|
||||
RUN mkdir -p /tmp/data/casc_configs
|
||||
COPY casc_templates/ /tmp/data/casc_configs/
|
||||
|
||||
# Set up directory structure for Cloudron
|
||||
RUN mkdir -p /app/data && \
|
||||
mkdir -p /tmp/data/jenkins_home
|
||||
|
||||
# Copy startup script
|
||||
COPY start.sh /app/code/
|
||||
RUN chmod +x /app/code/start.sh
|
||||
|
||||
# Copy NGINX configuration
|
||||
COPY nginx.conf /app/code/
|
||||
|
||||
# Copy supervisor configuration
|
||||
COPY supervisor.conf /etc/supervisor/conf.d/
|
||||
|
||||
# Use the cloudron user for Jenkins
|
||||
RUN usermod -a -G jenkins cloudron && \
|
||||
chown -R cloudron:cloudron /tmp/data
|
||||
|
||||
WORKDIR /app/data
|
||||
|
||||
# Entry point
|
||||
CMD ["/app/code/start.sh"]
|
97
Cloudron/jenkins.knownelement.com/JenkinsBulldNotes.md
Normal file
97
Cloudron/jenkins.knownelement.com/JenkinsBulldNotes.md
Normal file
@@ -0,0 +1,97 @@
|
||||
# Jenkins for Cloudron - Build Notes
|
||||
|
||||
This document provides instructions for building, testing, and deploying the Jenkins package to Cloudron.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Cloudron server (version 5.4.0 or higher)
|
||||
- Docker installed on your build machine
|
||||
- Cloudron CLI tool installed (`npm install -g cloudron`)
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
jenkins-cloudron/
|
||||
├── CloudronManifest.json # Package definition
|
||||
├── Dockerfile # Docker image build instructions
|
||||
├── start.sh # Initialization script
|
||||
├── nginx.conf # NGINX configuration
|
||||
├── supervisor.conf # Supervisor configuration for process management
|
||||
├── logo.png # App icon (128x128 PNG)
|
||||
├── casc_templates/ # Jenkins Configuration as Code templates
|
||||
│ ├── default.yaml # Default authentication config
|
||||
│ ├── ldap.yaml # LDAP authentication config
|
||||
│ └── oauth.yaml # OAuth/OIDC authentication config
|
||||
```
|
||||
|
||||
## Building the Package
|
||||
|
||||
1. Create a directory for your package and place all files in the appropriate structure.
|
||||
|
||||
2. Download a Jenkins logo (128x128 PNG) and save it as `logo.png`
|
||||
|
||||
3. Build the Docker image:
|
||||
```bash
|
||||
cloudron build
|
||||
```
|
||||
|
||||
4. Test the package locally:
|
||||
```bash
|
||||
cloudron install —image cloudron/jenkins
|
||||
```
|
||||
|
||||
## Authentication Configuration
|
||||
|
||||
The package supports three authentication methods:
|
||||
|
||||
1. **Default (Local)**: Uses Jenkins’ built-in user database
|
||||
2. **LDAP**: Uses Cloudron’s LDAP server for authentication
|
||||
3. **OAuth/OIDC**: Uses Cloudron’s OAuth service for single sign-on
|
||||
|
||||
The authentication method is automatically configured based on the presence of environment variables provided by Cloudron.
|
||||
|
||||
## Testing
|
||||
|
||||
After installation, test the following:
|
||||
|
||||
1. **Basic functionality**:
|
||||
- Access Jenkins through your Cloudron dashboard
|
||||
- Verify the initial admin password works
|
||||
- Create a simple pipeline job
|
||||
|
||||
2. **Authentication**:
|
||||
- Test LDAP integration by enabling the LDAP addon
|
||||
- Test OAuth/OIDC integration by enabling the OAuth addon
|
||||
- Verify user permissions are correctly applied
|
||||
|
||||
3. **Persistence**:
|
||||
- Install plugins through the Jenkins UI
|
||||
- Restart the app to verify plugins persist
|
||||
- Check that job configurations are maintained
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **Jenkins doesn’t start**: Check logs using `cloudron logs -f`
|
||||
- **Authentication issues**: Verify the correct addons are enabled and configuration is applied
|
||||
- **Permission problems**: Check the ownership and permissions of files in `/app/data`
|
||||
|
||||
## Updating Jenkins
|
||||
|
||||
When a new version of Jenkins is released, update the Dockerfile to pull the latest version and rebuild the package.
|
||||
|
||||
## Additional Notes
|
||||
|
||||
- The package uses Jenkins Configuration as Code (JCasC) to automate the setup process
|
||||
- Jenkins runs as the `cloudron` user for proper permissions
|
||||
- Files in `/app/data/jenkins_home` are persisted across restarts and updates
|
||||
- Initial admin password is set to ‘adminpass’ for local authentication
|
||||
|
||||
## Deployment to Cloudron App Store
|
||||
|
||||
If you wish to publish your app to the Cloudron App Store:
|
||||
|
||||
1. Update the CloudronManifest.json with your details
|
||||
2. Test thoroughly on your own Cloudron instance
|
||||
3. Follow the Cloudron App Publishing guidelines
|
||||
|
||||
Happy CI/CD with Jenkins on Cloudron!
|
55
Cloudron/jenkins.knownelement.com/nginx.conf
Normal file
55
Cloudron/jenkins.knownelement.com/nginx.conf
Normal file
@@ -0,0 +1,55 @@
|
||||
worker_processes 1;
|
||||
error_log stderr;
|
||||
pid /run/nginx.pid;
|
||||
daemon off;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
}
|
||||
|
||||
http {
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Disable access logs to stdout - Cloudron handles these
|
||||
access_log off;
|
||||
|
||||
server {
|
||||
listen 8000;
|
||||
|
||||
client_max_body_size 50M;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Required for Jenkins websocket connections
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
proxy_read_timeout 90;
|
||||
proxy_redirect http://127.0.0.1:8080 $scheme://$host;
|
||||
|
||||
# Fix potential security issues
|
||||
proxy_cookie_path / "/; HTTPOnly; Secure";
|
||||
}
|
||||
|
||||
# Special config for OIDC callback
|
||||
location /securityRealm/finishLogin {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
}
|
50
Cloudron/jenkins.knownelement.com/start.sh
Normal file
50
Cloudron/jenkins.knownelement.com/start.sh
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Jenkins home directory
|
||||
JENKINS_HOME=/app/data/jenkins_home
|
||||
|
||||
# Create necessary directories if they don't exist
|
||||
if [[ ! -d "${JENKINS_HOME}" ]]; then
|
||||
echo "Initializing Jenkins home directory"
|
||||
mkdir -p "${JENKINS_HOME}"
|
||||
cp -r /tmp/data/jenkins_home/* "${JENKINS_HOME}/" || true
|
||||
# Copy plugins
|
||||
mkdir -p "${JENKINS_HOME}/plugins"
|
||||
cp -r /tmp/data/plugins/* "${JENKINS_HOME}/plugins/" || true
|
||||
# Create directory for JCasC
|
||||
mkdir -p "${JENKINS_HOME}/casc_configs"
|
||||
fi
|
||||
|
||||
# Apply proper permissions
|
||||
chown -R cloudron:cloudron "${JENKINS_HOME}"
|
||||
|
||||
# Set up Jenkins environment variables
|
||||
export JENKINS_HOME
|
||||
export JENKINS_OPTS="--httpPort=8080"
|
||||
|
||||
# Disable setup wizard
|
||||
export JAVA_OPTS="-Djenkins.install.runSetupWizard=false"
|
||||
|
||||
# Setup JCasC configuration based on environment
|
||||
if [[ -n "${CLOUDRON_OAUTH_CLIENT_ID}" ]]; then
|
||||
echo "Setting up OAuth authentication"
|
||||
envsubst < /tmp/data/casc_configs/oauth.yaml > "${JENKINS_HOME}/casc_configs/oauth.yaml"
|
||||
export CASC_JENKINS_CONFIG="${JENKINS_HOME}/casc_configs/oauth.yaml"
|
||||
elif [[ -n "${CLOUDRON_LDAP_SERVER}" ]]; then
|
||||
echo "Setting up LDAP authentication"
|
||||
envsubst < /tmp/data/casc_configs/ldap.yaml > "${JENKINS_HOME}/casc_configs/ldap.yaml"
|
||||
export CASC_JENKINS_CONFIG="${JENKINS_HOME}/casc_configs/ldap.yaml"
|
||||
else
|
||||
echo "Using default authentication"
|
||||
envsubst < /tmp/data/casc_configs/default.yaml > "${JENKINS_HOME}/casc_configs/default.yaml"
|
||||
export CASC_JENKINS_CONFIG="${JENKINS_HOME}/casc_configs/default.yaml"
|
||||
fi
|
||||
|
||||
# Configure Jenkins URL
|
||||
JENKINS_URL="${CLOUDRON_APP_ORIGIN}"
|
||||
echo "Setting Jenkins URL to ${JENKINS_URL}"
|
||||
export JENKINS_URL
|
||||
|
||||
# Start supervisord, which will start NGINX and Jenkins
|
||||
exec /usr/bin/supervisord --nodaemon -c /etc/supervisor/supervisord.conf
|
18
Cloudron/jenkins.knownelement.com/supervisor.conf
Normal file
18
Cloudron/jenkins.knownelement.com/supervisor.conf
Normal file
@@ -0,0 +1,18 @@
|
||||
[program:nginx]
|
||||
command=nginx -c /app/code/nginx.conf
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
autorestart=true
|
||||
|
||||
[program:jenkins]
|
||||
command=java -Djava.awt.headless=true -Djenkins.model.Jenkins.slaveAgentPort=50000 -Dhudson.model.UsageStatistics.disabled=true %(ENV_JAVA_OPTS)s -jar /usr/share/java/jenkins.war --httpPort=8080 --webroot=/var/cache/jenkins/war %(ENV_JENKINS_OPTS)s
|
||||
directory=/app/data/jenkins_home
|
||||
user=cloudron
|
||||
environment=HOME="/app/data/jenkins_home",USER="cloudron"
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
autorestart=true
|
Reference in New Issue
Block a user