-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathJenkinsfile
More file actions
140 lines (139 loc) · 6.68 KB
/
Copy pathJenkinsfile
File metadata and controls
140 lines (139 loc) · 6.68 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
pipeline {
agent {
label 'labo_agent'
}
environment {
GIT_REPO = 'git@github.st.com:STInternal-CS-Authentication/STSELib_Validation.git'
DATE = java.time.LocalDate.now()
}
stages {
stage('Clone repository') {
steps {
script {
dir("${BUILD_ID}")
{
bat 'git clone %GIT_REPO% .'
bat 'git checkout main'
bat 'git submodule update --init'
}
}
}
}
stage('Checkout STSELib') {
steps {
dir("${BUILD_ID}/Middleware/STSELib") {
script {
if (params.STSELIB_PR?.trim()) {
bat "git fetch origin +refs/pull/%STSELIB_PR%/head:pr-%STSELIB_PR%"
bat "git checkout pr-%STSELIB_PR%"
} else {
echo "No STSELIB_PR provided, keeping submodule revision"
}
}
}
}
}
stage('Build project') {
steps {
dir("${BUILD_ID}") {
script {
bat '''"C:\\ST\\STM32CubeIDE_1.16.1\\STM32CubeIDE\\stm32cubeide.exe" ^
--launcher.suppressErrors ^
-nosplash ^
-application org.eclipse.cdt.managedbuilder.core.headlessbuild ^
-data .\\temp ^
-importAll .\\Application\\STSE_Test_project\\STM32CubeIDE^
-I .\\..\\..\\..\\Middleware\\EasyTest\\src ^
-build STSE_Test_project/Debug'''
}
}
}
}
stage('Perform Functional Test') {
steps {
dir("${BUILD_ID}") {
script {
// Get the current date in YYYY-MM-DD format
bat 'c:\\ST\\STM32CubeCLT_1.18.0\\STM32CubeProgrammer\\bin\\STM32_Programmer_CLI.exe -c port=SWD freq=4000 sn=0669FF564957886687062320 -w .\\Application\\STSE_Test_project\\STM32CubeIDE\\Debug\\STSE_Test_project_Debug.elf'
bat 'c:\\ST\\STM32CubeCLT_1.18.0\\STM32CubeProgrammer\\bin\\STM32_Programmer_CLI.exe -c port=SWD freq=4000 sn=0669FF564957886687062320 -rst'
try {
bat 'python .\\Middleware\\STSE_CI_CD\\Tools\\com_logger\\com_logger.py .\\Middleware\\STSE_CI_CD\\Tools\\com_logger\\com_logger_config.json'
} catch (Exception e) {
bat """
powershell -Command "python .\\Middleware\\STSE_CI_CD\\Tools\\com_logger\\md_to_html.py test_report.md STSELib_${BUILD_ID}_${DATE}_test_report.html"
"""
error("Build failed due to an error: ${e.message}")
}
bat """
powershell -Command "python .\\Middleware\\STSE_CI_CD\\Tools\\com_logger\\md_to_html.py test_report.md STSELib_${BUILD_ID}_${DATE}_test_report.html"
"""
}
}
}
}
stage('Generate Documentation') {
steps {
dir("${BUILD_ID}/Middleware/STSELib/doc/resources/") {
script {
bat 'doxygen STSELib.doxyfile'
}
}
}
}
}
post {
always {
// Get the current date in YYYY-MM-DD format
dir("${BUILD_ID}") {
script {
archiveArtifacts artifacts: '*.html', fingerprint: true
}
}
dir("${BUILD_ID}/Middleware/") {
script {
// Remove everything in STSELib/doc/resources except __html and Pictures
bat '''
REM Remove all folders except __html and Pictures
for /d %%D in ("STSELib\\doc\\resources\\*") do (
if /i not "%%~nxD"=="__html" if /i not "%%~nxD"=="Pictures" rmdir /s /q "%%D"
)
REM Remove all files except those in __html and Pictures
for %%F in ("STSELib\\doc\\resources\\*") do (
if /i not "%%~nxF"=="__html" if /i not "%%~nxF"=="Pictures" del /q "%%F"
)
'''
// Remove the resources@tmp folder before zipping
bat '''
REM Remove the resources@tmp folder
if exist "STSELib\\doc\\resources@tmp" rmdir /s /q "STSELib\\doc\\resources@tmp"
'''
// Create the documentation release package
bat """
powershell -Command "Compress-Archive -Path 'STSELib\\doc\\*' -DestinationPath 'STSELib_nightly_${BUILD_ID}_${DATE}_documentation.zip' -Force"
"""
// Remove unwanted files and folders from STSELib
bat '''
REM Remove unwanted folders
if exist "STSELib\\.github" rmdir /s /q "STSELib\\.github"
if exist "STSELib\\.vscode" rmdir /s /q "STSELib\\.vscode"
if exist "STSELib\\doc" rmdir /s /q "STSELib\\doc"
REM Remove unwanted files
if exist "STSELib\\.gitignore" del /q "STSELib\\.gitignore"
if exist "STSELib\\.gitmodules" del /q "STSELib\\.gitmodules"
if exist "STSELib\\.pre-commit-config.yaml" del /q "STSELib\\.pre-commit-config.yaml"
if exist "STSELib\\CODE_OF_CONDUCT.md" del /q "STSELib\\CODE_OF_CONDUCT.md"
if exist "STSELib\\CONTRIBUTING.md" del /q "STSELib\\CONTRIBUTING.md"
'''
// Create the release file including build number and date
bat """
powershell -Command "Compress-Archive -Path 'STSELib\\*' -DestinationPath 'STSELib_nightly_${BUILD_ID}_${DATE}.zip' -Force"
"""
// Archive the release in Jenkins
archiveArtifacts artifacts: "STSELib_nightly_${BUILD_ID}_*", fingerprint: true
}
}
// Clean-up the workspace
deleteDir()
}
}
}