You've already forked OpenIntegrations
							
							
				mirror of
				https://github.com/Bayselonarrend/OpenIntegrations.git
				synced 2025-10-30 23:47:46 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			137 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
		
			Vendored
		
	
	
	
			
		
		
	
	
			137 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
		
			Vendored
		
	
	
	
| def runCommand(String command) {
 | |
|     if (isUnix()) {
 | |
|         sh(script: command)
 | |
|     } else {
 | |
|         bat(script: command)
 | |
|     }
 | |
| }
 | |
| 
 | |
| def runLibraryTest(String libraryName, String configPath) {
 | |
|     catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {   
 | |
|         script {
 | |
|             runCommand("\"C:\\Program Files\\1cv8\\8.3.18.1208\\bin\\1cv8c.exe\" /IBConnectionString \"Srvr=\"\"DEVSRV\"\";Ref=\"\"OpenIntegrations\"\";\" /C\"RunUnitTests=${configPath}\"")
 | |
|         
 | |
|             timeout(time: 60, unit: 'MINUTES') {
 | |
|                 waitUntil {
 | |
|                     fileExists "./test_results/${libraryName}.code"
 | |
|                 }
 | |
|             }
 | |
| 
 | |
|             if (fileExists("./test_results/${libraryName}.report")) {
 | |
|                 def reportContent = readFile("./test_results/${libraryName}.report")
 | |
|                 echo "=== ${libraryName} report content ==="
 | |
|                 echo reportContent
 | |
|                 echo "=========================="
 | |
|             } else {
 | |
|                 echo "WARNING: ${libraryName}.report file not found"
 | |
|             }
 | |
| 
 | |
|             def exitCode = readFile("./test_results/${libraryName}.code").trim().replaceAll("[^0-9]", "")
 | |
|             echo "Exit code for ${libraryName}: ${exitCode}"
 | |
|             if (exitCode != "0") {
 | |
|                 error "Tests ${libraryName} failed with exit code: ${exitCode}"
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| def shouldRunStage(stageName) {
 | |
|     try {
 | |
|         if (!env.STAGES_CONFIG) {
 | |
|             echo "[WARN] STAGES_CONFIG not set. Assuming stage '${stageName}' is ENABLED."
 | |
|             return true
 | |
|         }
 | |
|         def config = readJSON text: env.STAGES_CONFIG
 | |
|         def value = config[stageName]
 | |
|         if (value == null) {
 | |
|             echo "[WARN] Stage '${stageName}' not found in config. Defaulting to DISABLED."
 | |
|             return false
 | |
|         }
 | |
|         return value == true
 | |
|     } catch (Exception e) {
 | |
|         echo "[ERROR] Failed to parse STAGES_CONFIG: ${e.message}"
 | |
|         echo "Raw config: ${env.STAGES_CONFIG}"
 | |
|         // Решите: включать stage по умолчанию или нет?
 | |
|         return false // или true — по вашему усмотрению
 | |
|     }
 | |
| }
 | |
| 
 | |
| 
 | |
| pipeline {
 | |
| 	agent {
 | |
| 		label 'windows'
 | |
| 	}
 | |
| 	stages {
 | |
| 
 | |
| 		stage('Prepare Test Results Directory') {
 | |
|             steps {
 | |
|                 script {
 | |
|                     runCommand '''
 | |
|                         if exist ".\\test_results" (
 | |
|                             rmdir /s /q ".\\test_results"
 | |
|                         )
 | |
|                         mkdir ".\\test_results"
 | |
|                     '''
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 		stage('Create ReportPortal launch'){
 | |
| 				steps{
 | |
| 					bat encoding: 'UTF-8', script:'chcp 65001 & oscript ./ci/os/rp_start.os "1C:Enterprise"'
 | |
| 				}
 | |
| 		}
 | |
| 
 | |
|         stage('Read stages config') {
 | |
|             steps {
 | |
|                 script {
 | |
|                     def configText = readFile './service/tests_config.json'
 | |
|                     env.STAGES_CONFIG = configText
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 		stage('Testing-BuildCheck') {
 | |
|             when {
 | |
|                 expression { return shouldRunStage('BuildCheck') }
 | |
|             }
 | |
| 			steps {
 | |
| 				script {
 | |
| 					def tests = [
 | |
| 						['BuildCheck', 'C:\\ProgramData\\Jenkins\\.jenkins\\workspace\\OpiBuild\\OpiMain\\service\\yaxunit_conf\\ru\\BuildCheck.json'],
 | |
| 					]
 | |
| 					for (test in tests) {
 | |
| 							runLibraryTest(test[0], test[1])
 | |
| 					}
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		stage('Testing-Neocities') {
 | |
|             when {
 | |
|                 expression { return shouldRunStage('Neocities') }
 | |
|             }
 | |
| 			steps {
 | |
| 				script {
 | |
| 					def tests = [
 | |
| 						['Neocities', 'C:\\ProgramData\\Jenkins\\.jenkins\\workspace\\OpiBuild\\OpiMain\\service\\yaxunit_conf\\ru\\Neocities.json'],
 | |
| 					]
 | |
| 					for (test in tests) {
 | |
| 						catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
 | |
| 							runLibraryTest(test[0], test[1])
 | |
| 						}
 | |
| 					}
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 	}
 | |
| 	post{
 | |
| 		always{
 | |
| 			script {
 | |
| 				catchError() {   
 | |
| 				    runCommand('oscript ./ci/os/rp_stop.os "ru"')
 | |
| 			    }	
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| } |