37 lines
1.2 KiB
Groovy
37 lines
1.2 KiB
Groovy
pipeline {
|
|
agent any
|
|
|
|
stages {
|
|
|
|
stage("Get code from repo") {
|
|
steps{
|
|
withCredentials([gitUsernamePassword(credentialsId: 'jenkinsgiteausername', gitToolName: 'git')]) {
|
|
// git url: "https://gitea.dev.osnawiki.de/ds/test" , branch: "main"
|
|
git url: "${repo}" , branch: "${Branch}"
|
|
}
|
|
}
|
|
}
|
|
|
|
stage("Build Docker image") {
|
|
steps {
|
|
script {
|
|
//def customImage = docker.build("my-image:${env.BUILD_ID}")
|
|
def imageName = "registry.dev.osnawiki.de/${env.Repo.replace('https://gitea.dev.osnawiki.de/','').replaceFirst('/','#').replaceAll('/','').replace('#','-')}:${env.Branch.toLowerCase()}-${env.BUILD_NUMBER}"
|
|
imageName = imageName.replace('--','-')
|
|
echo "Baue Image ${imageName}"
|
|
customImage = docker.build(imageName)
|
|
}
|
|
}
|
|
}
|
|
|
|
stage("Push images") {
|
|
steps {
|
|
script {
|
|
withDockerRegistry(credentialsId: 'registrycredentials', url: "https://registry.dev.osnawiki.de") {
|
|
customImage.push("latest")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |