Updated jenkinsfile for testing
parent
78061f064d
commit
6146538345
|
@ -1,11 +1,142 @@
|
|||
pipeline {
|
||||
agent any
|
||||
agent { label 'built-in' }
|
||||
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
echo 'Jenkinsfile for oglive-builder'
|
||||
}
|
||||
}
|
||||
options {
|
||||
timestamps()
|
||||
// Conserva la concurrencia como en el job original (no añadimos disableConcurrentBuilds)
|
||||
skipDefaultCheckout(true) // Haremos el checkout con los parámetros manualmente
|
||||
}
|
||||
|
||||
parameters {
|
||||
string(name: 'OGLIVE_BUILDER_BRANCH', defaultValue: 'main',
|
||||
description: 'What branch of repository oglive-builder to work in.')
|
||||
string(name: 'OGCLONE_ENGINE_BRANCH', defaultValue: 'main',
|
||||
description: 'What branch of repository ogclone-engine to pick files from.')
|
||||
string(name: 'OGREPOSITORY_BRANCH', defaultValue: 'main',
|
||||
description: 'What branch of repository ogrepository to pick files from.')
|
||||
booleanParam(name: 'REUSE_PREV_FS', defaultValue: true,
|
||||
description: 'Whether to reuse the virtual filesystem from the previous build or to start from scratch.')
|
||||
}
|
||||
|
||||
environment {
|
||||
CODENAME = 'noble' // Igual que en tu script actual (hardcoded)
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Workspace cleanup (pre-build)') {
|
||||
steps {
|
||||
// Equivalente al PreBuildCleanup del plugin ws-cleanup
|
||||
wsCleanup()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Checkout oglive-builder') {
|
||||
steps {
|
||||
checkout([
|
||||
$class: 'GitSCM',
|
||||
userRemoteConfigs: [[
|
||||
url: 'https://ognproject.evlt.uma.es/gitea/opengnsys/oglive-builder.git',
|
||||
credentialsId: 'gitea-unizar'
|
||||
]],
|
||||
branches: [[ name: "refs/heads/${params.OGLIVE_BUILDER_BRANCH}" ]],
|
||||
extensions: []
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build ogLive') {
|
||||
steps {
|
||||
sh '''#!/bin/bash
|
||||
set -euo pipefail
|
||||
export CODENAME="${CODENAME}" ## hardcoded at the moment
|
||||
|
||||
echo ========================= Parameters
|
||||
echo OGLIVE_BUILDER_BRANCH=${OGLIVE_BUILDER_BRANCH}
|
||||
echo OGCLONE_ENGINE_BRANCH=${OGCLONE_ENGINE_BRANCH}
|
||||
echo OGREPOSITORY_BRANCH=${OGREPOSITORY_BRANCH}
|
||||
echo REUSE_PREV_FS=${REUSE_PREV_FS}
|
||||
echo CODENAME=${CODENAME}
|
||||
|
||||
echo ========================= Clone/fetch clone-engine repo
|
||||
if [[ -d ogclone-engine-repo ]]; then
|
||||
cd ogclone-engine-repo; git fetch; git checkout "${OGCLONE_ENGINE_BRANCH}"; cd ..
|
||||
else
|
||||
git clone -c http.sslVerify=false --branch "${OGCLONE_ENGINE_BRANCH}" \
|
||||
https://ognproject.evlt.uma.es/gitea/opengnsys/ogclone-engine.git ogclone-engine-repo
|
||||
fi
|
||||
HEAD=$(git --git-dir ./ogclone-engine-repo/.git rev-parse HEAD)
|
||||
echo "ogclone-engine HEAD: $HEAD"
|
||||
|
||||
echo ========================= Clone/fetch ogrepository repo
|
||||
if [[ -d ogrepository-repo ]]; then
|
||||
cd ogrepository-repo; git fetch; git checkout "${OGREPOSITORY_BRANCH}"; cd ..
|
||||
else
|
||||
git clone -c http.sslVerify=false --branch "${OGREPOSITORY_BRANCH}" \
|
||||
https://ognproject.evlt.uma.es/gitea/opengnsys/ogrepository.git ogrepository-repo
|
||||
fi
|
||||
HEAD=$(git --git-dir ./ogrepository-repo/.git rev-parse HEAD)
|
||||
echo "ogrepository HEAD: $HEAD"
|
||||
|
||||
echo ========================= Take stuff out of the ogclone-engine repo
|
||||
mkdir -p shared
|
||||
mkdir -p engine
|
||||
cp -a ./ogclone-engine-repo/ogclient/{bin,etc,lib,scripts} shared/
|
||||
cp -a ./ogclone-engine-repo/ogclient/lib/engine/bin engine/
|
||||
git --git-dir ./ogclone-engine-repo/.git log --date format:r%Y%m%d --format=%ad.%h -1 > gitrelease
|
||||
|
||||
echo ========================= Take stuff out of the ogrepository repo
|
||||
mkdir -p ogrepo-ssh-key
|
||||
cp ./ogrepository-repo/installer/ssh-keys/opengnsys ogrepo-ssh-key/
|
||||
cp ./ogrepository-repo/installer/ssh-keys/opengnsys.pub ogrepo-ssh-key/
|
||||
|
||||
# echo ========================= Fetch deb packages from the artefacts server
|
||||
# AGENT_DEB=$(env - /bin/ls -t /mnt/srv/artefactos/ogagent/*.deb 2>/dev/null | head -n 1)
|
||||
# BROWSER_DEB=$(env - /bin/ls -t /mnt/srv/artefactos/ogbrowser/* | head -n 1)
|
||||
# echo "Found agent package '$AGENT_DEB' and browser package '$BROWSER_DEB'"
|
||||
# cp -vf $AGENT_DEB $BROWSER_DEB .
|
||||
|
||||
echo ========================= Build docker image
|
||||
docker build --build-arg OPENGNSYS_HEAD="$HEAD" -t opengnsys/mkoglive . ## invalidate cache when $HEAD changes
|
||||
rm -rf shared engine gitrelease ogrepo-ssh-key
|
||||
|
||||
echo ========================= Build ogLive
|
||||
if [[ "${REUSE_PREV_FS}" == "false" ]]; then
|
||||
echo "Not reusing old build"
|
||||
sudo chown user:user "$WORKSPACE/ogclient" || true
|
||||
rm -rf ogclient
|
||||
else
|
||||
echo "Reusing old build. In the following 'ls' output there should be something"
|
||||
ls -la ogclient/ || true
|
||||
fi
|
||||
mkdir -p ogclient ## run this as user; otherwise docker may create it as root
|
||||
if [[ "zuser" != "z$(stat --format %U ogclient)" ]]; then
|
||||
echo "warning: directory 'ogclient' not owned by user 'user'"
|
||||
fi
|
||||
|
||||
docker run --rm --name mkoglive --privileged=true \
|
||||
--volume "$PWD/ogclient:/var/lib/tftpboot/ogclient" \
|
||||
opengnsys/mkoglive --codename "$CODENAME" --loglevel debug
|
||||
|
||||
echo Uploading to the artefactos NFS share
|
||||
[[ -d /mnt/srv ]] || mount /mnt
|
||||
cp -av ogclient/ogLive-*.iso /mnt/srv/artefactos/oglive/ || true
|
||||
|
||||
echo Cleaning up
|
||||
sudo chown jenkins:jenkins "$WORKSPACE/ogclient" || true
|
||||
rm -vf ogclient/ogclient.sqfs* ogclient/ogLive-*.iso ogclient/*.iso.sum ogclient/oginitrd.img* ogclient/ogvmlinuz* || true
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Si te interesa conservar el ISO como artefacto de Jenkins, descomenta el 'post' siguiente y
|
||||
// mueve/duplica el borrado de ficheros para que ocurra después del archiveArtifacts.
|
||||
// post {
|
||||
// success {
|
||||
// archiveArtifacts artifacts: 'ogclient/ogLive-*.iso, ogclient/*.iso.sum', allowEmptyArchive: true
|
||||
// }
|
||||
// always {
|
||||
// wsCleanup()
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue