mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 07:15:49 +00:00
Nexus, Jenkins init
This commit is contained in:
parent
53b47529be
commit
d1ec84da93
3 changed files with 38 additions and 6 deletions
|
@ -4,14 +4,16 @@ pipeline {
|
|||
pollSCM('H/5 * * * *') // Watches the `dev` branch
|
||||
}
|
||||
environment {
|
||||
DOCKERHUB_CREDENTIALS = credentials('nalexx6-dockerhub-pass')
|
||||
DOCKERHUB_CREDENTIALS = credentials('nalexxgd-docker-pass')
|
||||
DOCKERHUB_USERNAME = "nalexxgd"
|
||||
NEXUS_URL = 'localhost:8081'
|
||||
ARTIFACT_VERSION = sh(script: "mvn help:evaluate -Dexpression=project.version -q -DforceStdout", returnStdout: true).trim()
|
||||
|
||||
}
|
||||
stages {
|
||||
stage('Checkout Code') {
|
||||
steps {
|
||||
git url: 'git@github.com:Nalexx06/spring-petclinic.git', credentialsId: "nalexx06_github_ssh", branch: 'dev'
|
||||
git url: 'https://github.com/spring-projects/spring-petclinic.git', branch: 'main'
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,15 +24,23 @@ pipeline {
|
|||
}
|
||||
stage('Upload to Nexus') {
|
||||
steps {
|
||||
sh './mvnw deploy -DaltDeploymentRepository=snapshots::default::${NEXUS_URL}'
|
||||
sh """
|
||||
mvn deploy:deploy-file \\
|
||||
-DgroupId=org \\
|
||||
-DartifactId=petclinic \\
|
||||
-Dversion=${ARTIFACT_VERSION}\\
|
||||
-Dpackaging=jar \\
|
||||
-Dfile=./target/spring-petclinic-${ARTIFACT_VERSION}.jar \\
|
||||
-DrepositoryId=maven-snapshots \\
|
||||
-Durl=http://${NEXUS_URL}/repository/maven-snapshots/ --settings settings.xml
|
||||
"""
|
||||
}
|
||||
}
|
||||
stage('Build Docker Image') {
|
||||
steps {
|
||||
script {
|
||||
def version = sh(script: "mvn help:evaluate -Dexpression=project.version -q -DforceStdout", returnStdout: true).trim()
|
||||
sh "docker build -t petclinic:${version} ."
|
||||
sh "docker tag petclinic:${version} ${DOCKERHUB_USERNAME}/petclinic:${version}"
|
||||
sh "docker build -t petclinic:${ARTIFACT_VERSION} ."
|
||||
sh "docker tag petclinic:${version} ${DOCKERHUB_USERNAME}/petclinic:${ARTIFACT_VERSION}"
|
||||
sh "docker login -u ${DOCKERHUB_USERNAME} -p ${DOCKERHUB_CREDENTIALS}"
|
||||
sh "docker push ${DOCKERHUB_USERNAME}/petclinic:${version}"
|
||||
}
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -331,6 +331,14 @@
|
|||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<id>mvn-central</id>
|
||||
<name>MVN central</name>
|
||||
<url>https://mvnrepository.com</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<profiles>
|
||||
|
|
14
settings.xml
Normal file
14
settings.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<settings>
|
||||
<servers>
|
||||
<server>
|
||||
<id>maven-releases</id>
|
||||
<username>admin</username>
|
||||
<password>admin</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>maven-snapshots</id>
|
||||
<username>admin</username>
|
||||
<password>admin</password>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
Loading…
Reference in a new issue