added Image sending to Gitea
Some checks failed
csharp-secdevops-pipeline-pod/pipeline/head There was a failure building this commit
Some checks failed
csharp-secdevops-pipeline-pod/pipeline/head There was a failure building this commit
This commit is contained in:
40
Jenkinsfile
vendored
40
Jenkinsfile
vendored
@@ -75,19 +75,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Docker Build (Kaniko)') {
|
|
||||||
steps {
|
|
||||||
container('kaniko') {
|
|
||||||
// Wir bauen das Image lokal im Pod-Speicher
|
|
||||||
// --context `pwd`: Wo liegt dein Code? (Hier!)
|
|
||||||
// --dockerfile: Wo liegt das Dockerfile?
|
|
||||||
// --no-push: Nur bauen, noch nicht hochladen
|
|
||||||
sh '/kaniko/executor --context `pwd` --dockerfile `pwd`/Dockerfile --no-push'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Set Build Name') {
|
stage('Set Build Name') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
@@ -95,7 +83,31 @@ pipeline {
|
|||||||
currentBuild.displayName = "v1.0.0-build-${env.BUILD_NUMBER}"
|
currentBuild.displayName = "v1.0.0-build-${env.BUILD_NUMBER}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage('Docker Build & Push') {
|
||||||
|
steps {
|
||||||
|
container('kaniko') {
|
||||||
|
// Nutze die ID, die du in Jenkins für den Token vergeben hast
|
||||||
|
withCredentials([usernamePassword(credentialsId: 'gitea-registry-token',
|
||||||
|
usernameVariable: 'GITEA_USER',
|
||||||
|
passwordVariable: 'GITEA_TOKEN')]) {
|
||||||
|
sh """
|
||||||
|
# Erstellt die Docker-Konfiguration für Kaniko
|
||||||
|
# Das $(echo ...) Kommando kombiniert User und Token für den Login
|
||||||
|
echo "{\\"auths\\":{\\"130.61.26.230:30080\\":{\\"auth\\":\\"\$(echo -n \${GITEA_USER}:\${GITEA_TOKEN} | base64)\\"}}}" > /kaniko/.docker/config.json
|
||||||
|
|
||||||
|
# Der Bau- und Push-Befehl
|
||||||
|
# Wir taggen das Image mit 'latest' UND der Build-Nummer zur Sicherheit
|
||||||
|
/kaniko/executor --context `pwd` \
|
||||||
|
--dockerfile `pwd`/Dockerfile \
|
||||||
|
--destination 130.61.26.230:30080/dev-master/secdevops-csharp-app:latest \
|
||||||
|
--destination 130.61.26.230:30080/dev-master/secdevops-csharp-app:${BUILD_NUMBER}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
|
|||||||
Reference in New Issue
Block a user