138 lines
5.2 KiB
Plaintext
138 lines
5.2 KiB
Plaintext
def repository = "registry.c.test-chamber-13.lan"
|
|
def label = "kubernetes-${UUID.randomUUID().toString()}"
|
|
def templateName = "pipeline-worker"
|
|
|
|
def mailBody
|
|
// def bitwardenReleases
|
|
def bitwardenInstalled
|
|
def bitwardenLatestServer
|
|
def bitwardenLatestRelease
|
|
|
|
pipeline {
|
|
|
|
agent {
|
|
kubernetes {
|
|
yaml functions.podYaml(
|
|
repo: repository,
|
|
templateName: templateName,
|
|
alpine: true,
|
|
)
|
|
}
|
|
}
|
|
|
|
stages {
|
|
stage ('Initalize Jenkins') {
|
|
steps {
|
|
script {
|
|
workspace = pwd()
|
|
}
|
|
}
|
|
}
|
|
|
|
stage ('Get latest Tag') {
|
|
steps {
|
|
container ('alpine') {
|
|
script {
|
|
sh """
|
|
if ! command -v curl &> /dev/null; then
|
|
apk add --no-cache curl
|
|
fi
|
|
if ! command -v jq &> /dev/null; then
|
|
apk add --no-cache jq
|
|
fi
|
|
"""
|
|
/*
|
|
bitwardenReleases = sh (
|
|
script: """
|
|
curl \
|
|
--location \
|
|
--silent \
|
|
--fail \
|
|
--request GET \
|
|
--url https://api.github.com/repos/bitwarden/server/releases/latest | \
|
|
jq -r 'select(.prerelease == false) | .tag_name[1:]'
|
|
""",
|
|
returnStdout: true
|
|
).trim()
|
|
*/
|
|
bitwardenInstalled = sh (
|
|
script: """
|
|
curl \
|
|
--location \
|
|
--silent \
|
|
--fail \
|
|
--request GET \
|
|
--url "https://bitwarden.smoothnet.org/admin/home/getinstalledwebversion" | \
|
|
sed -e 's/"//g'
|
|
""",
|
|
returnStdout: true
|
|
).trim()
|
|
bitwardenLatestServer = sh (
|
|
script: """
|
|
curl \
|
|
--location \
|
|
--silent \
|
|
--fail \
|
|
--request GET \
|
|
--url "https://bitwarden.smoothnet.org/admin/home/getlatestversion?project=Core" | \
|
|
sed -e 's/"//g'
|
|
""",
|
|
returnStdout: true
|
|
).trim()
|
|
bitwardenLatestWeb = sh (
|
|
script: """
|
|
curl \
|
|
--location \
|
|
--silent \
|
|
--fail \
|
|
--request GET \
|
|
--url "https://bitwarden.smoothnet.org/admin/home/getlatestversion?project=Web" | \
|
|
sed -e 's/"//g'
|
|
""",
|
|
returnStdout: true
|
|
).trim()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage ("Send Mail") {
|
|
steps {
|
|
script {
|
|
if (bitwardenInstalled != bitwardenLatestServer || bitwardenInstalled != bitwardenLatestWeb) {
|
|
mailBody = """Dear Bitwarden Admin,
|
|
A new version of bitwarden was released:
|
|
Server: v${bitwardenLatestServer}
|
|
Web: v${bitwardenLatestWeb}
|
|
Currently installed version: v${bitwardenInstalled}
|
|
|
|
Please login to bitwarden-admin to check for updates.
|
|
Bitwarden Admin
|
|
https://bitwarden.smoothnet.org/admin
|
|
Docker Containers
|
|
admin: https://hub.docker.com/r/bitwarden/admin/tags
|
|
api: https://hub.docker.com/r/bitwarden/api/tags
|
|
attachments: https://hub.docker.com/r/bitwarden/attachments/tags
|
|
icons: https://hub.docker.com/r/bitwarden/icons/tags
|
|
identity: https://hub.docker.com/r/bitwarden/notifications/tags
|
|
notifications: https://hub.docker.com/r/bitwarden/notifications/tags
|
|
web: https://hub.docker.com/r/bitwarden/web/tags
|
|
"""
|
|
|
|
echo mailBody
|
|
emailext(
|
|
body: mailBody,
|
|
mimeType: 'text/plain',
|
|
replyTo: '${DEFAULT_REPLYTO}',
|
|
subject: '${DEFAULT_SUBJECT}',
|
|
to: "nhyatt@smoothnet.org",
|
|
)
|
|
} else {
|
|
println "Bitwarden is up to date!"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|