#!groovy node { try { // add a polling sequence to the job properties([pipelineTriggers([[$class: 'SCMTrigger', scmpoll_spec: 'H/5 * * * *']])]) //notifyBuild('STARTED') // checkout the branch stage("Checkout") { checkout scm } echo "STARTING PIPELINE FOR BRANCH ${env.BRANCH_NAME}" // read the project json file def json = readJSON file: "${env.WORKSPACE}\\Projects.json" def jsonVersion = readJSON file: "${env.WORKSPACE}\\Version.json" def projects = json.projects.project def workspace = env.WORKSPACE def analysisDirectory = "${env.WORKSPACE}\\${env.ANALYSIS_OUTPUT}" def codecoverageDirectory = "${env.WORKSPACE}\\${env.CODECOVERAVE_OUTPUT}" def unittestDirectory = "${env.UNITTEST_OUTPUT}" def coberturaDirectory = "${env.CODECOVERAVE_OUTPUT}" def builds = [:] def nugets = [:] def tests = [:] def analysis = [:] def archiveFiles = [:] def assemblyVersion = "" def productVersion = "" // def majorVersion = VersionNumber(versionNumberString: '${BUILD_DATE_FORMATTED, "yyyy"}', projectStartDate : '2018-01-01', worstResultForIncrement: "SUCCESS") // def minorVersion = jsonVersion.version // def buildVersion = VersionNumber(versionNumberString: '${BUILD_WEEK}.${BUILD_NUMBER}', projectStartDate : '2018-01-01', worstResultForIncrement: "SUCCESS") def shortCommit = commitHashForBuild(currentBuild.rawBuild) stage("Prepearing workspace") { echo "VERSION: ${jsonVersion.version} COMMIT HASH: ${shortCommit}" // create analysis directories echo "CREATING ANALYSIS DIRECTORY '${analysisDirectory}'" new File(analysisDirectory).mkdirs() // create unit test code coverage directories echo "CREATING CODECOVERAGE DIRECTORY '${codecoverageDirectory}'" new File(codecoverageDirectory).mkdirs() // create unit test directories echo "CREATING UNITTEST DIRECTORY '${env.WORKSPACE}\\${env.UNITTEST_OUTPUT}'" new File("${env.WORKSPACE}\\${env.UNITTEST_OUTPUT}").mkdirs() // crafting assembly version assemblyVersion = "${jsonVersion.version}.${env.BUILD_NUMBER}" // setting product version if(env.BRANCH_NAME == "master") { productVersion = "prod-" + assemblyVersion + "-${shortCommit}" } else { productVersion = "dev-" + assemblyVersion + "-${shortCommit}" } echo "PRODUCT VERSION IS NOW ${productVersion}" echo "ASSEMBLY VERSION IS NOW ${assemblyVersion}" echo "JSON VERSION ${jsonVersion.version}" // changing assembly versions bat returnStdout: false, script: "\"${env.ASSEMBLY_CHANGER_EXE}\" -s \"${env.WORKSPACE}\" -v ${assemblyVersion} -i \"${productVersion}\" -c ${env.COMPANY} -p ${env.COPYRIGHT} -t ${env.TRADEMARK}" } for(int t = 0; t action instanceof jenkins.scm.api.SCMRevisionAction } return scmAction?.revision?.hash } class ToolBox { def getDirectory(String filePath) { def index = org.apache.commons.io.FilenameUtils.indexOfLastSeparator(filePath) return filePath.substring(0, index) } }