jenkinsfile three

This commit is contained in:
nkatanaeva 2021-06-09 12:07:55 +04:00
parent 67bd727a6a
commit 8dd506c69d
2 changed files with 52 additions and 1 deletions

13
build/Jenkinsfile vendored
View file

@ -85,7 +85,8 @@ stage ('image build and load') {
steps {
script {
pom = readMavenPom file: "pom.xml";
docker.build registry + ":${pom.version}"
env.POM_VERSION = ${pom.version}
docker.build registry + ":$POM_VERSION"
}
script {
docker.withRegistry( '', REGISTRY_CREDENTIAL ) {
@ -97,6 +98,16 @@ stage ('image build and load') {
}
}
}
post
{
success
{
script
{
env.ARTIFACT_VERSION = $POM_VERSION
}
}
}
}
}

40
deployment/Jenkinsfile vendored Normal file
View file

@ -0,0 +1,40 @@
pipeline {
agent any
environment {
NEXUS_VERSION = "nexus3"
NEXUS_PROTOCOL = "http"
NEXUS_URL = "172.19.0.3:8081"
NEXUS_REPOSITORY = "maven-nexus-repo"
NEXUS_CREDENTIAL_ID = "e6072e08-87bc-481e-9e4a-55d506546356"
REGISTRY = "http://localhost:8281/repository/docker_snapshots/"
REGISTRY_CREDENTIAL = "deployment"
}
}
triggers {
}
stages {
stage {
steps {
build job: 'build', parameters: [
string(name: 'artifact_version', value: env.ARTIFACT_VERSION)
], wait: true
}
}
stage('run') {
steps {
script {
withCredentials([usernameColonPassword(credentialsId: 'deployment', variable: 'DEPLOYMENT')]) {
sh '''
curl -u "$DEPLOYMENT" http://${NEXUS_URL}/repository/${NEXUS_REPOSITORY}/org/springframework/samples/spring-petclinic/2.4.2/spring-petclinic-2.4.2.jar >output
(java -jar spring-petclinic-2.4.2.jar --server.port=8083>> server.log 2>&1&)
nohup java -jar spring-petclinic-2.4.2.jar --server.port=8083>> server.log 2>&1&
'''
}
}
}
}
}
}