forked from spring-guides/gs-spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPromotion_Jenkins
106 lines (104 loc) · 3.89 KB
/
Promotion_Jenkins
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
pipeline {
agent any
environment {
JURL = 'https://soleng.jfrog.io/'
RT_URL = 'https://soleng.jfrog.io/artifactory'
TOKEN = credentials('art_token')
ARTIFACTORY_LOCAL_DEV_REPO = 'meghraj-maven-dev-local'
ARTIFACTORY_LOCAL_STAGING_REPO = 'meghraj-maven-staging-local'
ARTIFACTORY_LOCAL_PROD_REPO = 'meghraj-maven-prod-local'
SERVER_ID = 'soleng'
}
tools {
maven "maven-3.8.6"
}
stages {
stage ('Config JFrgo CLI') {
steps {
sh 'jf c add ${SERVER_ID} --interactive=false --overwrite=true --access-token=${TOKEN} --url=${JURL}'
sh 'jf config use ${SERVER_ID}'
}
}
stage ('Ping to Artifactory') {
steps {
sh 'jf rt ping'
}
}
stage ('Config Maven'){
steps {
dir('complete'){
sh 'jf mvnc --repo-resolve-releases=meghraj-virtual --repo-resolve-snapshots=meghraj-virtual --repo-deploy-releases=meghraj-virtual --repo-deploy-snapshots=meghraj-virtual'
}
}
}
stage('Compile') {
steps {
echo 'Compiling'
dir('complete') {
sh 'jf mvn clean test-compile -Dcheckstyle.skip -DskipTests'
}
}
}
stage ('Upload artifact') {
steps {
dir('complete') {
sh 'jf mvn clean deploy -Dcheckstyle.skip -DskipTests --build-name="${JOB_NAME}" --build-number=${BUILD_ID}'
}
}
}
stage ('Publish build info') {
steps {
// Collect environment variables for the build
sh 'jf rt bce "${JOB_NAME}" ${BUILD_ID}'
//Collect VCS details from git and add them to the build
sh 'jf rt bag "${JOB_NAME}" ${BUILD_ID}'
//Publish build info
sh 'jf rt bp "${JOB_NAME}" ${BUILD_ID} --build-url=${BUILD_URL}'
//Promote the build
sh 'jf rt bpr --status=Development "${JOB_NAME}" ${BUILD_ID} ${ARTIFACTORY_LOCAL_DEV_REPO}'
//Set properties to the files
sh 'jf rt sp --build="${JOB_NAME}"/${BUILD_ID} "status=Development"'
}
}
stage ('Scan build for stagging') {
steps {
sh 'JFROG_CLI_LOG_LEVEL=DEBUG jf rt bs --fail=false "${JOB_NAME}" ${BUILD_ID}'
}
}
stage ('Approve Release for Production') {
options {
timeout(time: 5, unit: 'MINUTES')
}
steps {
input message: "Are we good to go to Production?"
}
}
stage ('entering the staging environment') {
steps {
sh 'jf rt bpr --source-repo=${ARTIFACTORY_LOCAL_DEV_REPO} --status=Staging "${JOB_NAME}" ${BUILD_ID} ${ARTIFACTORY_LOCAL_STAGING_REPO}'
//Set properties to the files
sh 'jf rt sp --build="${JOB_NAME}"/${BUILD_ID} "status=Staging"'
}
}
stage ('Scan build for production') {
steps {
sh 'JFROG_CLI_LOG_LEVEL=DEBUG jf rt bs --fail=false "${JOB_NAME}" ${BUILD_ID}'
}
}
stage ('Approve Release for Production') {
options {
timeout(time: 5, unit: 'MINUTES')
}
steps {
input message: "Are we good to go to Production?"
}
}
stage ('Release for Production') {
steps {
sh 'jf rt bpr --source-repo=${ARTIFACTORY_LOCAL_STAGING_REPO} --status=Production "${JOB_NAME}" ${BUILD_ID} ${ARTIFACTORY_LOCAL_PROD_REPO}'
//Set properties to the files
sh 'jf rt sp --build="${JOB_NAME}"/${BUILD_ID} "status=Production"'
}
}
}
}