|
| 1 | +pipeline { |
| 2 | + agent { |
| 3 | + label 'labo_agent' |
| 4 | + } |
| 5 | + environment { |
| 6 | + GIT_REPO = 'git@github.st.com:STInternal-CS-Authentication/STSELib_Validation.git' |
| 7 | + DATE = java.time.LocalDate.now() |
| 8 | + } |
| 9 | + stages { |
| 10 | + stage('Clone repository') { |
| 11 | + steps { |
| 12 | + script { |
| 13 | + dir("${BUILD_ID}") |
| 14 | + { |
| 15 | + bat 'git clone %GIT_REPO% .' |
| 16 | + bat 'git checkout main' |
| 17 | + bat 'git submodule update --init' |
| 18 | + } |
| 19 | + } |
| 20 | + } |
| 21 | + } |
| 22 | + stage('Checkout STSELib ) { |
| 23 | + steps { |
| 24 | + script { |
| 25 | + dir("${BUILD_ID}/Middleware/STSELib") |
| 26 | + checkout scm |
| 27 | + } |
| 28 | + } |
| 29 | + } |
| 30 | + stage('Build project') { |
| 31 | + steps { |
| 32 | + dir("${BUILD_ID}") { |
| 33 | + script { |
| 34 | + bat '''"C:\\ST\\STM32CubeIDE_1.16.1\\STM32CubeIDE\\stm32cubeide.exe" ^ |
| 35 | + --launcher.suppressErrors ^ |
| 36 | + -nosplash ^ |
| 37 | + -application org.eclipse.cdt.managedbuilder.core.headlessbuild ^ |
| 38 | + -data .\\temp ^ |
| 39 | + -importAll .\\Application\\STSE_Test_project\\STM32CubeIDE^ |
| 40 | + -I .\\..\\..\\..\\Middleware\\EasyTest\\src ^ |
| 41 | + -build STSE_Test_project/Debug''' |
| 42 | + } |
| 43 | + } |
| 44 | + } |
| 45 | + } |
| 46 | + stage('Perform Functional Test') { |
| 47 | + steps { |
| 48 | + dir("${BUILD_ID}") { |
| 49 | + script { |
| 50 | + // Get the current date in YYYY-MM-DD format |
| 51 | + 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' |
| 52 | + bat 'c:\\ST\\STM32CubeCLT_1.18.0\\STM32CubeProgrammer\\bin\\STM32_Programmer_CLI.exe -c port=SWD freq=4000 sn=0669FF564957886687062320 -rst' |
| 53 | + try { |
| 54 | + bat 'python .\\Middleware\\STSE_CI_CD\\Tools\\com_logger\\com_logger.py .\\Middleware\\STSE_CI_CD\\Tools\\com_logger\\com_logger_config.json' |
| 55 | + } catch (Exception e) { |
| 56 | + bat """ |
| 57 | + powershell -Command "python .\\Middleware\\STSE_CI_CD\\Tools\\com_logger\\md_to_html.py test_report.md STSELib_${BUILD_ID}_${DATE}_test_report.html" |
| 58 | + """ |
| 59 | + error("Build failed due to an error: ${e.message}") |
| 60 | + } |
| 61 | + bat """ |
| 62 | + powershell -Command "python .\\Middleware\\STSE_CI_CD\\Tools\\com_logger\\md_to_html.py test_report.md STSELib_${BUILD_ID}_${DATE}_test_report.html" |
| 63 | + """ |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | + } |
| 68 | + stage('Generate Documentation') { |
| 69 | + steps { |
| 70 | + dir("${BUILD_ID}/Middleware/STSELib/doc/resources/") { |
| 71 | + script { |
| 72 | + bat 'doxygen STSELib.doxyfile' |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | + } |
| 78 | + post { |
| 79 | + always { |
| 80 | + // Get the current date in YYYY-MM-DD format |
| 81 | + dir("${BUILD_ID}") { |
| 82 | + script { |
| 83 | + archiveArtifacts artifacts: '*.html', fingerprint: true |
| 84 | + } |
| 85 | + } |
| 86 | + dir("${BUILD_ID}/Middleware/") { |
| 87 | + script { |
| 88 | + // Remove everything in STSELib/doc/resources except __html and Pictures |
| 89 | + bat ''' |
| 90 | + REM Remove all folders except __html and Pictures |
| 91 | + for /d %%D in ("STSELib\\doc\\resources\\*") do ( |
| 92 | + if /i not "%%~nxD"=="__html" if /i not "%%~nxD"=="Pictures" rmdir /s /q "%%D" |
| 93 | + ) |
| 94 | + |
| 95 | + REM Remove all files except those in __html and Pictures |
| 96 | + for %%F in ("STSELib\\doc\\resources\\*") do ( |
| 97 | + if /i not "%%~nxF"=="__html" if /i not "%%~nxF"=="Pictures" del /q "%%F" |
| 98 | + ) |
| 99 | + ''' |
| 100 | + // Remove the resources@tmp folder before zipping |
| 101 | + bat ''' |
| 102 | + REM Remove the resources@tmp folder |
| 103 | + if exist "STSELib\\doc\\resources@tmp" rmdir /s /q "STSELib\\doc\\resources@tmp" |
| 104 | + ''' |
| 105 | + // Create the documentation release package |
| 106 | + bat """ |
| 107 | + powershell -Command "Compress-Archive -Path 'STSELib\\doc\\*' -DestinationPath 'STSELib_nightly_${BUILD_ID}_${DATE}_documentation.zip' -Force" |
| 108 | + """ |
| 109 | + // Remove unwanted files and folders from STSELib |
| 110 | + bat ''' |
| 111 | + REM Remove unwanted folders |
| 112 | + if exist "STSELib\\.github" rmdir /s /q "STSELib\\.github" |
| 113 | + if exist "STSELib\\.vscode" rmdir /s /q "STSELib\\.vscode" |
| 114 | + if exist "STSELib\\doc" rmdir /s /q "STSELib\\doc" |
| 115 | + REM Remove unwanted files |
| 116 | + if exist "STSELib\\.gitignore" del /q "STSELib\\.gitignore" |
| 117 | + if exist "STSELib\\.gitmodules" del /q "STSELib\\.gitmodules" |
| 118 | + if exist "STSELib\\.pre-commit-config.yaml" del /q "STSELib\\.pre-commit-config.yaml" |
| 119 | + if exist "STSELib\\CODE_OF_CONDUCT.md" del /q "STSELib\\CODE_OF_CONDUCT.md" |
| 120 | + if exist "STSELib\\CONTRIBUTING.md" del /q "STSELib\\CONTRIBUTING.md" |
| 121 | + ''' |
| 122 | + // Create the release file including build number and date |
| 123 | + bat """ |
| 124 | + powershell -Command "Compress-Archive -Path 'STSELib\\*' -DestinationPath 'STSELib_nightly_${BUILD_ID}_${DATE}.zip' -Force" |
| 125 | + """ |
| 126 | + // Archive the release in Jenkins |
| 127 | + archiveArtifacts artifacts: "STSELib_nightly_${BUILD_ID}_*", fingerprint: true |
| 128 | + } |
| 129 | + } |
| 130 | + // Clean-up the workspace |
| 131 | + deleteDir() |
| 132 | + } |
| 133 | + } |
| 134 | +} |
0 commit comments