-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriverSwRequest.groovy
More file actions
204 lines (179 loc) · 10.1 KB
/
driverSwRequest.groovy
File metadata and controls
204 lines (179 loc) · 10.1 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
pipeline {
agent none
environment {
LOGS_PATH = "Code"
ZIP_PATH = "C:\\Program Files\\7-Zip\\7z.exe"
ARTIFACTORY_URL = 'http://ec2-3-122-95-11.eu-central-1.compute.amazonaws.com:8081/artifactory/'
TARGET_PATH = 'cruisecontrolsystem/DriverSwRequest/'
MODEL_BUILD_LOG = 'DriverSwRequestBuildLog.json'
BUILD_ZIP = "build.zip"
ANALYZER_PATH = ".\\Design\\DriverSwRequest\\pipeline\\analyze\\"
ZIP_OUTPUT_PATH = "${env.ANALYZER_PATH}${env.BUILD_ZIP}"
BUILD_FOLDER_PATH = ".\\Design\\DriverSwRequest\\pipeline\\analyze\\build\\"
DRIVER_SW_REQUEST_ERT_RTW_ZIP = "DriverSwRequest_ert_rtw.zip"
CODE_GEN_FOLDER_PATH = ".\\Code\\codegen\\"
DRIVER_SW_REQUEST_ERT_RTW_PATH = ".\\Code\\codegen\\DriverSwRequest_ert_rtw\\"
CODE_GEN_OUTPUT_PATH = "${env.CODE_GEN_FOLDER_PATH}${env.DRIVER_SW_REQUEST_ERT_RTW_ZIP}"
}
stages {
stage('Verify') {
agent {
label 'EC2MatlabServer' // Label for Windows agent
}
steps {
script {
// This job executes the Model Advisor Check for the model
matlabScript("DriverSwRequestModelAdvisor;")
}
}
post {
always {
archiveArtifacts artifacts: "$LOGS_PATH/logs/, ./Design/DriverSwRequest/pipeline/analyze/**/*"
}
}
}
stage('Build') {
agent {
label 'LocalMatlabServer' // Label for Windows agent
}
steps {
script {
// This job performs code generation on the model
matlabScript("DriverSwRequestBuild;")
//bat "\"${ZIP_PATH}\" a -tzip \"${ZIP_OUTPUT_PATH}\" \"${ANALYZER_PATH}\""
bat "\"${ZIP_PATH}\" a -tzip \"${ZIP_OUTPUT_PATH}\" \"${BUILD_FOLDER_PATH}\\*\""
// Set up HTTP request parameters
def buildUploadUrl = "${env.ARTIFACTORY_URL}/${env.TARGET_PATH}/${env.BUILD_ZIP}"
def folderToUpload = "Design/DriverSwRequest/pipeline/analyze/${env.BUILD_ZIP}"
// Perform HTTP request to upload the file
withCredentials([usernamePassword(credentialsId: 'artifactory_credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh "curl -u ${USERNAME}:${PASSWORD} -X PUT --data-binary @${folderToUpload} ${buildUploadUrl}"
}
// Set up HTTP request parameters
def uploadUrl = "${env.ARTIFACTORY_URL}/${env.TARGET_PATH}/${env.MODEL_BUILD_LOG}"
def fileToUpload = "Code/logs/${env.MODEL_BUILD_LOG}"
// Perform HTTP request to upload the file
withCredentials([usernamePassword(credentialsId: 'artifactory_credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh "curl -u ${USERNAME}:${PASSWORD} -X PUT --data-binary @${fileToUpload} ${uploadUrl}"
}
// Zip the contents of crs_controller_ert_rtw into crs_controller_ert_rtw.zip
bat "\"${ZIP_PATH}\" a -tzip \"${CODE_GEN_FOLDER_PATH}${DRIVER_SW_REQUEST_ERT_RTW_ZIP}\" \"${DRIVER_SW_REQUEST_ERT_RTW_PATH}*\""
// Set up HTTP request parameters for the upload
def ertRtwUploadUrl = "${env.ARTIFACTORY_URL}/${env.TARGET_PATH}/${env.DRIVER_SW_REQUEST_ERT_RTW_ZIP}"
def ertRtwFolderToUpload = "${env.CODE_GEN_FOLDER_PATH}${env.DRIVER_SW_REQUEST_ERT_RTW_ZIP}"
// Perform HTTP request to upload the zipped folder
withCredentials([usernamePassword(credentialsId: 'artifactory_credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
bat "curl -u ${USERNAME}:${PASSWORD} -T ${ertRtwFolderToUpload} ${ertRtwUploadUrl}"
}
}
}
post {
always {
archiveArtifacts artifacts: "$LOGS_PATH/codegen/DriverSwRequest_ert_rtw/**/*, ./Design/DriverSwRequest/pipeline/analyze/**/*, $LOGS_PATH/logs/"
}
}
}
stage('Testing') {
agent {
label 'EC2MatlabServer' // Label for EC2 agent
}
steps {
script {
// This job executes the unit tests defined in the collection
matlabScript("DriverSwRequestTest;")
}
}
post {
always {
archiveArtifacts artifacts: "./Design/DriverSwRequestTest/pipeline/analyze/**/*, $LOGS_PATH/logs/, $LOGS_PATH/codegen/DriverSwRequestTest_ert_rtw/**/*"
//junit './Design/DriverSwRequestTest/pipeline/analyze/testing/DriverSwRequestTestJUnitFormatTestResults.xml'
}
}
}
stage('Package') {
agent {
label 'EC2MatlabServer' // Label for Windows agent
}
steps {
script {
// Set up HTTP request parameters
def downloadUrl = "${env.ARTIFACTORY_URL}/${env.TARGET_PATH}/${env.MODEL_BUILD_LOG}"
def fileToDownload = "Code/logs/${env.MODEL_BUILD_LOG}"
// Perform HTTP request to download the file
withCredentials([usernamePassword(credentialsId: 'artifactory_credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
bat "curl -u %USERNAME%:%PASSWORD% -o ${fileToDownload} ${downloadUrl}"
}
// Set up HTTP request parameters
def buildDownloadUrl = "${env.ARTIFACTORY_URL}/${env.TARGET_PATH}/${env.BUILD_ZIP}"
def folderToDownload = "${ZIP_OUTPUT_PATH}"
// Perform HTTP request to upload the file
withCredentials([usernamePassword(credentialsId: 'artifactory_credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
bat "curl -u %USERNAME%:%PASSWORD% -o ${folderToDownload} ${buildDownloadUrl}"
}
// Unzip the build.zip file
bat "\"${ZIP_PATH}\" x \"${ZIP_OUTPUT_PATH}\" -o\"${BUILD_FOLDER_PATH}\""
// Delete the build.zip file after extraction
bat "del \"${ZIP_OUTPUT_PATH}\""
// The summary report is generated which shows results from the previous stages.
// Any logs that were generated in the previous stages will be cleared after this stage
// Set up HTTP request parameters
def codeGenDownloadUrl = "${env.ARTIFACTORY_URL}/${env.TARGET_PATH}/${env.DRIVER_SW_REQUEST_ERT_RTW_ZIP}"
def codeGenFolderToDownload = "${CODE_GEN_OUTPUT_PATH}"
// Perform HTTP request to upload the file
withCredentials([usernamePassword(credentialsId: 'artifactory_credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
bat "curl -u %USERNAME%:%PASSWORD% -o ${codeGenFolderToDownload} ${codeGenDownloadUrl}"
}
// Unzip the build.zip file
bat "\"${ZIP_PATH}\" x \"${CODE_GEN_OUTPUT_PATH}\" -o\"${DRIVER_SW_REQUEST_ERT_RTW_PATH}\""
// Delete the build.zip file after extraction
bat "del \"${CODE_GEN_OUTPUT_PATH}\""
echo "The model DriverSwRequest has been checked"
echo "There is a Summary report generated DriverSwRequestSummaryReport.html which is present in analyze folder"
matlabScript("generateXMLFromLogs('DriverSwRequest'); generateHTMLReport('DriverSwRequest'); deleteLogs;")
}
}
post {
always {
archiveArtifacts artifacts: "Design/DriverSwRequest/pipeline/analyze/**/*, $LOGS_PATH/codegen/DriverSwRequest_ert_rtw/**/*"
}
}
}
stage('Deploy') {
agent {
label 'EC2MatlabServer' // Label for Windows agent
}
steps {
script {
echo "Any deployments of code can be made here"
echo "All artifacts of previous stage can be found here"
// Curl command to download artifacts
// bat "curl.exe --location --output \"$ARTIFACTS_DOWNLOAD_PATH/DriverSwRequestArtifacts.zip\" --header \"PRIVATE-TOKEN: %CIPROJECTTOKEN%\" \"%CI_SERVER_URL%/api/v4/projects/%CI_PROJECT_ID%/jobs/artifacts/%CI_COMMIT_BRANCH%/download?job=DriverSwRequestPackage\""
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'Design/DriverSwRequest/pipeline/analyze/verify/',
reportFiles: 'DriverSwRequestModelAdvisorReport.html',
reportName: 'Model Advisor Report'
])
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'Design/DriverSwRequest/pipeline/analyze/package/',
reportFiles: 'DriverSwRequestSummaryReport.html',
reportName: 'Summary Report'
])
}
}
post {
always {
archiveArtifacts artifacts: "Design/DriverSwRequest/pipeline/analyze/**/*, $LOGS_PATH/codegen/DriverSwRequest_ert_rtw/**/*"
}
}
}
}
}
def matlabScript(String script) {
bat "matlab -nodesktop -batch \"openProject('CruiseControlSystem.prj'); ${script}\""
}