#!/usr/bin/env groovy @Library("product-pipelines-shared-library") _ // Automated release, promotion and dependencies properties([ // Include the automated release parameters for the build release.addParams(), // Dependencies of the project that should trigger builds dependencies([]) ]) // Performs release promotion. No other stages will be run if (params.MODE == "PROMOTE") { release.promote(params.VERSION_TO_PROMOTE) { infrapool, sourceVersion, targetVersion, assetDirectory -> // Any assets from sourceVersion Github release are available in assetDirectory // Any version number updates from sourceVersion to targetVersion occur here // Any publishing of targetVersion artifacts occur here // Anything added to assetDirectory will be attached to the Github Release //Note: assetDirectory is on the infrapool agent, not the local Jenkins agent. // Publish container images to internal registry //INFRAPOOL_EXECUTORV2_AGENT_0.agentSh "summon --yaml 'RUBYGEMS_API_KEY: !var rubygems/api-key' ${toolsDirectory}/bin/publish-rubygem slosilo" INFRAPOOL_EXECUTORV2_AGENT_0.agentSh "./publish.sh" INFRAPOOL_EXECUTORV2_AGENT_0.agentSh "cp slosilo*.gem ${assetDirectory}" } release.copyEnterpriseRelease(params.VERSION_TO_PROMOTE) return } pipeline { agent { label 'conjur-enterprise-common-agent' } triggers { cron(getDailyCronString()) } environment { // Sets the MODE to the specified or autocalculated value as appropriate MODE = release.canonicalizeMode() } options { timestamps() buildDiscarder(logRotator(daysToKeepStr: '30')) } stages { stage('Get InfraPool Agent') { steps { script { INFRAPOOL_EXECUTORV2_AGENT_0 = getInfraPoolAgent.connected(type: "ExecutorV2", quantity: 1, duration: 1)[0] INFRAPOOL_EXECUTORV2_RHEL_EE_AGENT_0 = getInfraPoolAgent.connected(type: "ExecutorV2RHELEE", quantity: 1, duration: 1)[0] } } } // Generates a VERSION file based on the current build number and latest version in CHANGELOG.md stage('Validate Changelog and set version') { steps { script { updateVersion(INFRAPOOL_EXECUTORV2_AGENT_0, "CHANGELOG.md", "${BUILD_NUMBER}") INFRAPOOL_EXECUTORV2_AGENT_0.agentStash name: 'version_file', includes: "VERSION" INFRAPOOL_EXECUTORV2_RHEL_EE_AGENT_0.agentUnstash name: 'version_file' } } } stage('Test') { parallel { stage('Run tests on EE') { steps { script { INFRAPOOL_EXECUTORV2_RHEL_EE_AGENT_0.agentSh './test.sh' } } post { always { script { INFRAPOOL_EXECUTORV2_RHEL_EE_AGENT_0.agentStash name: 'eeTestResults', includes: 'spec/reports/*.xml', allowEmpty:true } }} } stage('Run tests') { steps { script { INFRAPOOL_EXECUTORV2_AGENT_0.agentSh './test.sh' INFRAPOOL_EXECUTORV2_AGENT_0.agentStash name: 'TestResults', includes: 'spec/coverage/*.xml', allowEmpty:true } } } } } stage('Release') { when { expression { MODE == "RELEASE" } } steps { script { release(INFRAPOOL_EXECUTORV2_AGENT_0) { billOfMaterialsDirectory, assetDirectory, toolsDirectory -> // Publish release artifacts to all the appropriate locations // Copy any artifacts to assetDirectory to attach them to the Github release // Publish container images to internal registry INFRAPOOL_EXECUTORV2_AGENT_0.agentSh "summon ${toolsDirectory}/bin/publish-rubygem slosilo" INFRAPOOL_EXECUTORV2_AGENT_0.agentSh "cp slosilo*.gem ${assetDirectory}" } } } } } post { always { dir('ee-results'){ unstash 'eeTestResults' } unstash 'TestResults' junit 'spec/reports/*.xml, ee-results/spec/reports/*.xml' cobertura coberturaReportFile: 'spec/coverage/coverage.xml' codacy action: 'reportCoverage', filePath: "spec/coverage/coverage.xml" releaseInfraPoolAgent(".infrapool/release_agents") } } }