182 lines
6.3 KiB
Groovy
182 lines
6.3 KiB
Groovy
#!groovy
|
|
|
|
def repository = "registry.c.test-chamber-13.lan"
|
|
def repositoryCreds = "harbor-repository-creds"
|
|
|
|
def workspace
|
|
def k8slensVersion
|
|
def jsNodeID
|
|
def doBuild = false
|
|
|
|
def label = "kubernetes-${UUID.randomUUID().toString()}"
|
|
def templateName = "pipeline-worker"
|
|
pipeline {
|
|
agent {
|
|
kubernetes {
|
|
yaml functions.podYaml(
|
|
repo: repository,
|
|
templateName: templateName,
|
|
alpine: true,
|
|
[
|
|
[
|
|
name: "node-14",
|
|
path: "${repository}/dockerhub/library/node:14",
|
|
command: "/bin/sh"
|
|
],
|
|
[
|
|
name: "node-16",
|
|
path: "${repository}/dockerhub/library/node:16",
|
|
command: "/bin/sh"
|
|
]
|
|
]
|
|
)
|
|
}
|
|
}
|
|
|
|
stages {
|
|
stage ('Initalize Jenkins') {
|
|
steps {
|
|
script {
|
|
workspace = pwd()
|
|
}
|
|
}
|
|
}
|
|
|
|
stage ('Get latest Tag') {
|
|
steps {
|
|
container ('alpine') {
|
|
script {
|
|
sh """
|
|
if ! command -v git &> /dev/null; then
|
|
apk add --no-cache git
|
|
fi
|
|
apk add --no-cache coreutils
|
|
"""
|
|
k8slensVersion = "refs/tags/" + sh (
|
|
script: """
|
|
git \
|
|
-c \'versionsort.suffix=-\' \
|
|
ls-remote https://gitea.smoothnet.org/nhyatt/openlens.git \'v*.*.*\' \
|
|
| cut \
|
|
--delimiter=\'/\' \
|
|
--fields=3 \
|
|
| sort \
|
|
-u \
|
|
| tail \
|
|
-n 1
|
|
""",
|
|
returnStdout: true
|
|
).trim()
|
|
}
|
|
}
|
|
script {
|
|
if (k8slensVersion ==~ 'refs\\/tags\\/v([5-9]|[0-9]{2,})\\.[0-9]+\\.[0-9]+$') {
|
|
if (k8slensVersion ==~ 'refs\\/tags\\/v5\\.5\\.[0-9]+$') {
|
|
echo "Version (${k8slensVersion}) is valid, we will build it with node 14."
|
|
doBuild = true
|
|
jsNodeID = 'node-14'
|
|
} else if (k8slensVersion ==~ 'refs\\/tags\\/v5\\.6\\.[0-9]+$') {
|
|
echo "Version (${k8slensVersion}) is valid, we will build it with node 16."
|
|
doBuild = true
|
|
jsNodeID = 'node-16'
|
|
} else if (k8slensVersion ==~ 'refs\\/tags\\/v6\\.[0-9]+\\.[0-9]+$') {
|
|
echo "Version (${k8slensVersion}) is valid, we will build it with node 16."
|
|
doBuild = true
|
|
jsNodeID = 'node-16'
|
|
} else {
|
|
echo "Version (${k8slensVersion}) is not valid, we will not build it."
|
|
}
|
|
} else {
|
|
echo "Version (${k8slensVersion}) is not valid, we will not build it."
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Pull K8S Lens Source Code') {
|
|
when {
|
|
expression {
|
|
return doBuild
|
|
}
|
|
}
|
|
steps {
|
|
script {
|
|
dir("lens") {
|
|
checkout ([
|
|
$class: "GitSCM",
|
|
branches: [
|
|
[
|
|
name: k8slensVersion,
|
|
],
|
|
],
|
|
userRemoteConfigs: [
|
|
[
|
|
url: "https://github.com/lensapp/lens.git",
|
|
],
|
|
],
|
|
extensions: [
|
|
[
|
|
$class: "CloneOption",
|
|
shallow: true,
|
|
],
|
|
[
|
|
$class: "CheckoutOption",
|
|
timeout: 2,
|
|
],
|
|
],
|
|
])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage ('Build K8S Lens') {
|
|
when {
|
|
expression {
|
|
return doBuild
|
|
}
|
|
}
|
|
steps {
|
|
container (jsNodeID) {
|
|
script {
|
|
sh """
|
|
apt-get update
|
|
apt-get install -y rpm
|
|
rm -rf /root/.npm
|
|
su - node
|
|
cd "${workspace}/lens"
|
|
make build
|
|
"""
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage ('Push Artifacts') {
|
|
when {
|
|
expression {
|
|
return doBuild
|
|
}
|
|
}
|
|
steps {
|
|
container('alpine') {
|
|
script {
|
|
def appName = sh (
|
|
script: """
|
|
printf '%s\\n' "\$(basename "\$(find ./ -name "*.AppImage")")"
|
|
""",
|
|
returnStdout: true
|
|
).trim()
|
|
functions.pushArtifact(
|
|
repoCreds: "nexus-generic-upload-bot",
|
|
fileName: appName,
|
|
filePath: workspace + "/lens/dist/",
|
|
fileURL: "https://nexus.c.test-chamber-13.lan/repository/generic/appimage/"
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|