-
Notifications
You must be signed in to change notification settings - Fork 7
/
ATG.groovy
152 lines (145 loc) · 5.26 KB
/
ATG.groovy
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/groovy
/**
* Function: Read configurations from Jenkins file and implements the DSL elements and hence you can extend the pipeline.
* Author : Amit Patil, Saurabh Singhal and Neeraj Sharama
* Date : 21 Apr'2017
* Params :
**/
import main.com.rocc.stages.impl.*
String WORKSPACE = pwd()
def call(body) {
def config = [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body()
try {
timestamps {
stage('\u2776 Initialize') {
try {
def wspace = "${WORKSPACE}"
def MAVEN_HOME = "${config.MAVEN_HOME}"
def ANT_HOME = "${config.ANT_HOME}"
env.MAVEN_HOME = "${MAVEN_HOME}"
env.ANT_HOME = "${ANT_HOME}"
env.wspace = "${wspace}"
env.PATH = "${MAVEN_HOME}/bin:${env.ANT_HOME}:${env.PATH}"
def buildNumber = "${env.BUILD_NUMBER}"
echo "\u001B[35m MAVEN_HOME => ${env.MAVEN_HOME}"
echo "\u001B[35m WSPACE => ${wspace}"
echo "\u001B[35m PATH => ${env.ANT_HOME}"
echo "\u001B[35m BUILD_NUMBER =>${buildNumber}"
}
catch (Exception groovyEx) {
echo groovyEx.getMessage()
echo groovyEx.getCause()
throw groovyEx
}
}
stage('\u2777 GetLatest') {
def co_obj = new GITCheckout()
co_obj.gitCheckout( "${WORKSPACE}")
def dl_obj = new ATGAntBuild()
dl_obj.copy( "${WORKSPACE}")
}
stage('\u2778 Compile Code') {
def dl_obj = new ATGAntBuild()
dl_obj.execAntBuild( "${WORKSPACE}", "${config.ANT_HOME}")
}
stage('\u2779 UnitTesting') {
if ("${config.EXEC_UNIT_TESTS}" == "true" ) {
def ut_obj = new UnitTesting()
ut_obj.execUnitTestCases( "${WORKSPACE}", "${config.ANT_HOME}")
ut_obj.publishReport( "${WORKSPACE}")
} else {
println "Unit Testing skipped"
}
}
stage('\u277A Sonar Analysis') {
if ("${config.EXEC_SONAR}" == "true" ) {
def sonar_obj = new SonarAnalysis()
sonar_obj.execSonarAnalysis("${WORKSPACE}", "${config.ANT_HOME}", "${config.JAVA_HOME}")
} else {
println "Sonar Analysis skipped"
}
}
stage('\u277B Assembling') {
if ("${config.EXEC_DEPLOYMENT}" == "true" ) {
script {
echo "Start Packaging"
parallel(
phase1: {
def dl_obj = new ATGAntBuild()
dl_obj.AssembleEAR("prod", "${config.CURRENT_Env}", "${WORKSPACE}", "${config.EXEC_FUNC_TESTS}", "${config.deployBranch}", "${config.ANT_HOME}")
echo "Deploying EAR on nexus repository"
dl_obj.NexusDeploy("${config.MAVEN_HOME}", "${WORKSPACE}", "prod" ,"${env.BUILD_NUMBER}" )
},
phase2: {
def dl_obj1 = new ATGAntBuild()
//dl_obj1.AssembleEAR("pub", "${config.CURRENT_Env}", "${WORKSPACE}", "${config.EXEC_FUNC_TESTS}", "${config.deployBranch}", "${config.ANT_HOME}")
//dl_obj1.NexusDeploy("${config.MAVEN_HOME}", "${WORKSPACE}", "pub" ,"${env.BUILD_NUMBER}" )
},
phase3: {
def dl_obj2 = new ATGAntBuild()
//dl_obj2.AssembleEAR("stg", "${config.CURRENT_Env}", "${WORKSPACE}", "${config.EXEC_FUNC_TESTS}", "${config.deployBranch}", "${config.ANT_HOME}")
//dl_obj2.NexusDeploy("${config.MAVEN_HOME}", "${WORKSPACE}", "stg" ,"${env.BUILD_NUMBER}")
}
)
}
}
}
stage('\u277C Deployment') {
if ("${config.EXEC_DEPLOYMENT}" == "true" ) {
def dl_obj1 = new ATGAntBuild()
dl_obj1.deployment( "${WORKSPACE}")
}
}
stage('\u277D Integration Testing') {
if ("${config.EXEC_DEPLOYMENT}" == "true" ) {
if ("${config.RUN_FUNC_TESTS}" == "true" ) {
build job: 'selenium_web'
} else {
println "Please run deployment before Functional Testing."
println "Function Testing Skipped"
}
}
}
stage('\u277E Zap Security Testing') {
if ("${config.EXEC_DEPLOYMENT}" == "true" ) {
if ("${config.EXEC_ZAP}" == "true" ) {
def dl_obj = new ATGAntBuild()
dl_obj.ZapSecurity( "${WORKSPACE}", "${config.ZAP_HOME}")
} else {
println "Please run deployment before Security Testing."
println "Security Testing Skipped"
}
}
}
stage('\u2776 \u0030 Jmeter Testing')
{
jmeter_workdir = ${WORKSPACE}+"@libs/DevOps/resources/config/username.properties"
Properties props = new Properties()
File propsFile = new File("$jmeter_workdir")
props.load(propsFile.newDataInputStream())
def jmeter_wspace_path = props.getProperty('jmeter_wspace_path')
if ("${config.EXEC_JMET}" == "true" )
{
node ("Perf-Simens-Jmeter")
{
def dl_obj = new JmeterAnalysis()
dl_obj.execJemeterAnalysis("${jmeter_wspace_path}")
}
}
else
{
println "Please run deployment before Jmeter Testing."
println "Jmeter Testing Skipped"
}
}
}
}
catch (Exception groovyEx) {
echo groovyEx.getMessage()
echo groovyEx.getCause()
throw groovyEx
}
}