scripts/Jenkinsfile
devaine 625df11b6d
Some checks failed
forgejo/scripts/pipeline/head There was a failure building this commit
/ desec-script (push) Has been cancelled
build: trying to see whether I can push to container registry
2026-11-11 20:42:02 -06:00

57 lines
1.3 KiB
Groovy

pipeline {
agent any
environment {
PROJECT_OWNER = "devaine"
PROJECT_NAME = "scripts"
}
stages {
stage("build-desec") {
environment {
SCRIPT_NAME = "desec"
}
steps {
// Reference: https://www.jenkins.io/doc/pipeline/steps/credentials-binding/
withCredentials([
string(
credentialsId: "FORGEJO_REGISTRY",
variable: "REGISTRY"
),
usernamePassword(
credentialsId: "FORGEJO_REGISTRY_LOGIN",
usernameVariable: "FORGEJO_USERNAME",
passwordVariable: "FORGEJO_PAT"
)
]) {
// Login to the Forgejo Registry
sh '''
printf "$FORGEJO_PAT" | docker login "$REGISTRY" -u "$FORGEJO_USERNAME" --password-stdin
'''
// Get into the desec-ip-sync directory
dir('./server/desec-ip-sync/') {
sh '''
docker buildx build -t "$REGISTRY"/"$PROJECT_OWNER"/"$PROJECT_NAME":$SCRIPT_NAME" .
docker push "$REGISTRY"/"$PROJECT_OWNER"/"$PROJECT_NAME":"$SCRIPT_NAME"
'''
}
}
// Clean workspace after build
cleanWs()
}
}
}
post {
always {
cleanWs(
cleanWhenNotBuilt: false,
deleteDirs: true,
disableDeferredWipeout: true,
notFailBuild: true,
patterns: [[pattern: ".gitignore", type: "INCLUDE"],
[pattern: ".propsfile", type: "EXCLUDE"]]
)
}
}
}