def runCommand(String command) { if (isUnix()) { sh(script: command) } else { bat(script: command) } } pipeline { agent { label 'windows' } stages { stage('Remove OInt from OneScript Lib') { steps { script { try { // Удаление каталога C:\Program Files\OneScript\lib\oint, если существует powershell encoding: 'UTF-8', script: ''' $dirPath = "C:\\Program Files\\OneScript\\lib\\oint" if (Test-Path $dirPath) { Write-Host "Каталог oint найден. Удаляем..." Remove-Item -Path $dirPath -Recurse -Force Write-Host "Каталог oint успешно удален." } else { Write-Host "Каталог oint не найден. Пропускаем удаление." } ''' // Проверяем, что каталог действительно удален powershell encoding: 'UTF-8', script: ''' $dirPath = "C:\\Program Files\\OneScript\\lib\\oint" if (Test-Path $dirPath) { Write-Error "Ошибка: Каталог oint всё ещё существует после попытки удаления!" exit 1 } else { Write-Host "Проверка: Каталог oint отсутствует после удаления." } ''' } catch (Exception e) { echo "Произошла ошибка при удалении каталога oint: ${e.getMessage()}" currentBuild.result = 'FAILURE' error("Удаление каталога oint завершено с ошибкой.") } } } } stage('Build OInt from source and decrypt secret data'){ steps{ powershell encoding: 'UTF-8', script:'cd ./src/en/OInt; opm build; opm install oint-1.28.0.ospx; del oint-1.28.0.ospx' withCredentials([string(credentialsId: 'gpgkey', variable: 'GPGKEY')]) { bat encoding: 'UTF-8', script:'gpg --quiet --batch --yes --decrypt --passphrase="%GPGKEY%" --output ./data.json ./data.json.gpg' } } } stage('Create ReportPortal launch'){ steps{ bat encoding: 'UTF-8', script:'chcp 65001 & oscript ./ci/os/rp_start.os' } } stage('Testing-Bitrix24') { steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_TokenManagement"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_ServerTime"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_PostsManagement"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_TaskManagement"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_CommentsManagement"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_WorkingWithDrive"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_Kanban"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_Timekeeping"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_ChatManagement"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_NotificationsManagement"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_TasksFieldsManagement"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_DepartmentsManagement"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B2_UsersManagement"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_LeadsManagement"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_DealsManagement"') } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { runCommand('1testrunner -run "./src/en/OInt/tests/Modules/internal/OPI_Tests.os" "B24_CalendarsManagement"') } } } } post{ always{ script { catchError() { runCommand('oscript ./ci/os/rp_stop.os "en"') } withCredentials([string(credentialsId: 'gpgkey', variable: 'GPGKEY')]) { bat encoding: 'UTF-8', script:'del "./data.json.gpg"' bat encoding: 'UTF-8', script:'gpg --batch --symmetric --cipher-algo AES256 --passphrase="%GPGKEY%" ./data.json' bat encoding: 'UTF-8', script:'del "./data.json"' } withCredentials([gitUsernamePassword(credentialsId: 'gitmain', gitToolName: 'Default')]) { bat "git config user.email vitaly.the.alpaca@gmail.com" bat 'git config user.name "Vitaly the Alpaca (bot)"' bat "git config --global core.ignorecase true" bat "git add ." bat 'git commit -m "Test data update (Jenkins)"' bat "git push origin HEAD:main" } } } } }