#!/usr/bin/env groovy /* groovylint-disable CompileStatic, ConsecutiveStringConcatenation, DuplicateNumberLiteral, DuplicateStringLiteral, LineLength, NestedBlockDepth, NoDef, VariableTypeRequired */ import groovy.transform.Field @Field String _DDrive = 'D:/' @Field String _SolutionName = '...' @Field String _GitCommitSeven = '...' @Field String _GitName = 'PDF-Text-Stripper' @Field String _AgentStaging = 'mestsa07ec-ecmeseaf' @Field String _DDriveNet = "${_DDrive}Framework4.8" @Field String _AgentProduction = 'messa08ec-ecmeseaf' @Field String _AgentDevelopment = 'mestsa003-mesedasvc' @Field String _ProgramFilesMSBuild = 'C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/MSBuild.exe' pipeline { agent { label env.JENKINS_ENVIRONMENT == 'Development' ? _AgentDevelopment : env.JENKINS_ENVIRONMENT == 'Staging' ? _AgentStaging : env.JENKINS_ENVIRONMENT == 'Production' ? _AgentProduction : 'Else' } parameters { string(name: 'GIT_SERVER', defaultValue: env.JENKINS_ENVIRONMENT == 'Development' ? 'mestsa003.infineon.com' : 'mestsa07ec.ec.local', description: 'git server') } stages { // stage('Git') { // steps { // bat(returnStatus: true, script: 'git init') // bat(returnStatus: true, script: 'git remote add origin \\\\' + params.GIT_SERVER + '\\Git\\' + _GitName + '.git') // bat(returnStatus: true, script: 'git pull origin master') // } // } stage('Setup') { steps { script { _SolutionName = "${env.JOB_NAME}" _GitCommitSeven = '1234567' // _GitCommitSeven = env.GIT_COMMIT.substring(0, 7) def files = findFiles(glob: '*.sln') if (files.length != 1) { error("Build failed because couldn't find a *.sln file") } echo """ ${files[0].name} ${files[0].path} ${files[0].directory} ${files[0].length} ${files[0].lastModified} """ _SolutionName = files[0].name.split('[.]sln')[0] } } } stage('Info') { steps { echo "_SolutionName ${_SolutionName}" // ... echo "BUILD_NUMBER ${env.BUILD_NUMBER}" // 11 echo "GIT_BRANCH ${env.GIT_BRANCH}" // origin/master echo "GIT_COMMIT ${env.GIT_COMMIT}" // 73b814069f2cf0173a62a8228815a9bc9ba93c41 echo "GIT_SERVER ${params.GIT_SERVER}" // ... echo "GIT_URL ${env.GIT_URL}" // D:\ProgramData\Git\....git echo "JENKINS_ENVIRONMENT ${env.JENKINS_ENVIRONMENT}" // 11 echo "JENKINS_URL ${env.JENKINS_URL}" // http://localhost:8080/ echo "JOB_NAME ${env.JOB_NAME}" // ... echo "WORKSPACE ${env.WORKSPACE}" // D:\.jenkins\_\... } } stage('Framework Build') { steps { echo "Build number is ${currentBuild.number}" bat(returnStatus: true, script: '"' + _ProgramFilesMSBuild + '" ' + '/ConsoleLoggerParameters:PerformanceSummary;ErrorsOnly; ' + '/DetailedSummary ' + '/m ' + '/property:Configuration=Debug;TargetFrameworkVersion=v4.8 ' + '/restore:True ' + '/target:Build ' + _SolutionName + '.sln') } } // stage('Force Fail') { // steps { // error("Build failed because of this and that..") // } // } } post { always { cleanWs() } } }