156 lines
3.5 KiB
Groovy
156 lines
3.5 KiB
Groovy
// Jenkinsfile for Rocky Man
|
|
pipeline {
|
|
agent {
|
|
kubernetes {
|
|
yaml """
|
|
apiVersion: v1
|
|
kind: Pod
|
|
metadata:
|
|
labels:
|
|
jenkins: agent
|
|
spec:
|
|
containers:
|
|
- name: docker
|
|
image: docker:24-dind
|
|
securityContext:
|
|
privileged: true
|
|
volumeMounts:
|
|
- name: docker-sock
|
|
mountPath: /var/run
|
|
command:
|
|
- dockerd-entrypoint.sh
|
|
- name: docker-cli
|
|
image: docker:24-cli
|
|
command:
|
|
- cat
|
|
tty: true
|
|
volumeMounts:
|
|
- name: docker-sock
|
|
mountPath: /var/run
|
|
- name: b2
|
|
image: backblazeit/b2:latest
|
|
command:
|
|
- cat
|
|
tty: true
|
|
volumes:
|
|
- name: docker-sock
|
|
emptyDir: {}
|
|
"""
|
|
}
|
|
}
|
|
|
|
parameters {
|
|
string(
|
|
name: 'VERSIONS',
|
|
defaultValue: '8.10 9.6 10.0',
|
|
description: 'Rocky Linux versions to build (space-separated)'
|
|
)
|
|
string(
|
|
name: 'B2_BUCKET_NAME',
|
|
defaultValue: 'rockyman',
|
|
description: 'B2 bucket name for uploads'
|
|
)
|
|
}
|
|
|
|
options {
|
|
buildDiscarder(logRotator(numToKeepStr: '10'))
|
|
timeout(time: 2, unit: 'HOURS')
|
|
}
|
|
|
|
stages {
|
|
stage('Checkout') {
|
|
steps {
|
|
checkout scm
|
|
}
|
|
}
|
|
|
|
stage('Build Docker Image') {
|
|
steps {
|
|
container('docker-cli') {
|
|
sh '''
|
|
docker build -t rocky-man:${BUILD_NUMBER} .
|
|
docker tag rocky-man:${BUILD_NUMBER} rocky-man:latest
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Build Man Pages') {
|
|
steps {
|
|
container('docker-cli') {
|
|
sh """
|
|
# Create output directories
|
|
mkdir -p ./html ./tmp
|
|
|
|
# Run the container to build man pages - FIXED ESCAPING
|
|
docker run --rm \\
|
|
-v \"\$(pwd)/html:/app/html\" \\
|
|
-v \"\$(pwd)/tmp:/data/tmp\" \\
|
|
rocky-man:${BUILD_NUMBER} \\
|
|
--versions ${params.VERSIONS} \\
|
|
--verbose
|
|
"""
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Archive Artifacts') {
|
|
steps {
|
|
archiveArtifacts artifacts: 'html/**/*', fingerprint: true, allowEmptyArchive: true
|
|
}
|
|
}
|
|
|
|
stage('Upload to B2') {
|
|
when {
|
|
expression { return params.B2_BUCKET_NAME != "" }
|
|
}
|
|
steps {
|
|
container('b2') {
|
|
withCredentials([
|
|
string(credentialsId: 'b2-app-id', variable: 'B2_APPLICATION_ID'),
|
|
string(credentialsId: 'b2-app-key', variable: 'B2_APPLICATION_KEY')
|
|
]) {
|
|
sh '''
|
|
# Modern B2 auth command
|
|
b2 account authorize-account-key \\
|
|
--applicationKeyId ${B2_APPLICATION_ID} \\
|
|
--key ${B2_APPLICATION_KEY}
|
|
|
|
# Verify auth (should succeed)
|
|
b2 account get-account-info
|
|
|
|
# Sync HTML contents
|
|
b2 sync \\
|
|
--allowEmptySource \\
|
|
--compareVersions size \\
|
|
--skip-perms \\
|
|
--threads 10 \\
|
|
./html/ \\
|
|
b2://${B2_BUCKET_NAME}/builds/${BUILD_NUMBER}/
|
|
|
|
# Verify upload
|
|
b2 ls b2://${B2_BUCKET_NAME}/builds/${BUILD_NUMBER}
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
success {
|
|
echo 'Build completed and uploaded to B2!'
|
|
}
|
|
failure {
|
|
echo 'Build failed!'
|
|
}
|
|
cleanup {
|
|
container('docker-cli') {
|
|
sh '''
|
|
docker rmi rocky-man:${BUILD_NUMBER} || true
|
|
docker rmi rocky-man:latest || true
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
} |