spring-petclinic/Jenkinsfile

78 lines
1.6 KiB
Text
Raw Normal View History

2025-02-04 10:20:36 +00:00
pipeline {
2025-02-04 12:22:32 +00:00
agent {
2025-02-05 14:38:15 +00:00
label 'worker5'
2025-02-04 12:22:32 +00:00
}
2025-02-04 11:56:42 +00:00
environment {
imageName = "spring-pet-clinic"
2025-02-05 12:12:41 +00:00
2025-02-04 11:56:42 +00:00
registryCredentials = "nexus-credentials"
2025-02-05 18:09:25 +00:00
registry = "localhost:9081"
2025-02-04 11:56:42 +00:00
dockerImage = ''
2025-02-05 18:09:25 +00:00
DOCKERHUB_CREDENTIALS="piachsecki-dockerhub"
2025-02-04 11:56:42 +00:00
}
2025-02-04 10:20:36 +00:00
tools {
maven 'm3'
}
2025-02-04 11:56:42 +00:00
2025-02-04 10:20:36 +00:00
stages {
2025-02-05 18:09:25 +00:00
2025-02-04 11:56:42 +00:00
stage ('Docker build') {
2025-02-04 11:58:21 +00:00
steps {
2025-02-05 12:12:41 +00:00
script {
2025-02-05 18:09:25 +00:00
sh '/usr/sbin/envShell.sh build -t piachsecki/spring-pet-clinic:latest .'
2025-02-05 12:16:45 +00:00
2025-02-04 12:12:41 +00:00
}
2025-02-04 11:56:42 +00:00
}
}
2025-02-05 18:29:14 +00:00
stage('Login to dockerhub') {
steps {
withCredentials([usernamePassword(credentialsId: 'piachsecki-dockerhub',
usernameVariable: 'DOCKERHUB_USER',
passwordVariable: 'DOCKERHUB_PASS')]) {
sh 'echo $DOCKERHUB_PASS | docker login -u $DOCKERHUB_USER --password-stdin'
}
2025-02-05 18:25:45 +00:00
}
2025-02-05 18:29:14 +00:00
}
2025-02-05 18:36:51 +00:00
stage('Login to Nexus') {
steps {
withCredentials([usernamePassword(credentialsId: 'nexus-credentials',
usernameVariable: 'NEXUS_USER',
passwordVariable: 'NEXUS_PASS')]) {
sh 'echo $NEXUS_PASS | docker login $registry -u $NEXUS_USER --password-stdin'
}
}
}
2025-02-05 18:25:45 +00:00
2025-02-05 18:09:25 +00:00
stage('Push') {
steps {
2025-02-05 18:30:39 +00:00
sh '/usr/sbin/envShell.sh push piachsecki/spring-pet-clinic:latest'
2025-02-05 18:09:25 +00:00
}
}
2025-02-05 14:39:43 +00:00
/*stage ('Build') {
2025-02-04 10:20:36 +00:00
steps {
2025-02-04 10:26:12 +00:00
sh './mvnw -B -DskipTests clean package'
2025-02-04 10:20:36 +00:00
}
}
stage ('Test') {
steps {
2025-02-04 10:26:12 +00:00
sh './mvnw test'
2025-02-04 10:20:36 +00:00
}
}
stage ('Deploy') {
steps {
2025-02-04 10:44:41 +00:00
sh 'echo "hello $USER"'
2025-02-04 10:20:36 +00:00
}
}
2025-02-05 14:39:43 +00:00
*/
2025-02-04 10:27:40 +00:00
}
2025-02-04 10:20:36 +00:00
}