|
| 1 | +pipeline { |
| 2 | + options { |
| 3 | + skipDefaultCheckout() |
| 4 | + timestamps() |
| 5 | + timeout(time: 120, unit: 'MINUTES') |
| 6 | + buildDiscarder(logRotator(numToKeepStr:'5')) |
| 7 | + } |
| 8 | + agent { |
| 9 | + label 'basic' |
| 10 | + } |
| 11 | + environment { |
| 12 | + HIDE_SITE = 'true' |
| 13 | + // Download Server locations (would very seldom change) |
| 14 | + BUILD_ROOT = '/home/data/httpd/download.eclipse.org' |
| 15 | + EP_ECLIPSE_ROOT = "${BUILD_ROOT}/eclipse" |
| 16 | + EP_EQUINOX_ROOT = "${BUILD_ROOT}/equinox" |
| 17 | + } |
| 18 | + stages { |
| 19 | + stage('Process input') { |
| 20 | + steps { |
| 21 | + script { |
| 22 | + env.DROP_ID = readParameter('DROP_ID') |
| 23 | + if (!"${DROP_ID}") { |
| 24 | + error("Parameter 'DROP_ID' is not specified") |
| 25 | + } |
| 26 | + env.CHECKPOINT = readParameter('CHECKPOINT') |
| 27 | + env.SIGNOFF_BUG = readParameter('SIGNOFF_BUG') |
| 28 | + env.TRAIN_NAME = readParameter('TRAIN_NAME') |
| 29 | + if (!"${TRAIN_NAME}") { |
| 30 | + error("Parameter 'TRAIN_NAME' is not specified") |
| 31 | + } |
| 32 | + def idMatcher = null |
| 33 | + if ((idMatcher = env.DROP_ID =~ /(?<type>I)(?<date>\d{8})-(?<time>\d{4})/).matches()) { |
| 34 | + assignEnvVariable('BUILD_LABEL', "${DROP_ID}") |
| 35 | + } else if ((idMatcher = env.DROP_ID =~ /(?<type>S)-(?<major>\d+)\.(?<minor>\d+)(?<service>\.\d+)?((M|RC)\d+[a-z]?)?-(?<date>\d{8})(?<time>\d{4})/).matches()) { |
| 36 | + assignEnvVariable('BUILD_LABEL', idMatcher.group('major') + '.' + idMatcher.group('minor') + (idMatcher.group('service') ?: '')) |
| 37 | + if ("${CHECKPOINT}") { |
| 38 | + error "Stable build DROP_ID=${DROP_ID} may only be promoted to release CHECKPOINT, which therefore must be empty: ${CHECKPOINT}" |
| 39 | + } |
| 40 | + } else { |
| 41 | + error "DROP_ID, ${DROP_ID}, did not match any expected pattern." |
| 42 | + } |
| 43 | + assignEnvVariable('BUILD_TYPE', idMatcher.group('type')) |
| 44 | + assignEnvVariable('REPO_BUILD_TYPE', 'I') |
| 45 | + assignEnvVariable('BUILD_TIMESTAMP', idMatcher.group('date') + idMatcher.group('time')) |
| 46 | + assignEnvVariable('REPO_ID', "I${idMatcher.group('date')}-${idMatcher.group('time')}") |
| 47 | + idMatcher = null // release matcher as it's not serializable |
| 48 | + |
| 49 | + assignEnvVariable('BUILD_LABEL_EQ', "${BUILD_LABEL}") |
| 50 | + assignEnvVariable('DROP_ID_EQ', "${DROP_ID}") |
| 51 | + |
| 52 | + sh 'curl -o buildproperties.shsource --fail https://download.eclipse.org/eclipse/downloads/drops4/${DROP_ID}/buildproperties.shsource' |
| 53 | + def STREAM = sh(returnStdout: true, script: 'source ./buildproperties.shsource && echo ${STREAM}').trim() |
| 54 | + def versionMatcher = STREAM =~ /(?<major>\d+)\.(?<minor>\d+).(?<service>\d+)/ |
| 55 | + if (!versionMatcher.matches()) { |
| 56 | + error "STREAM must contain major, minor, and service versions, such as '4.37.0', but found: ${STREAM}" |
| 57 | + } |
| 58 | + assignEnvVariable('BUILD_MAJOR', versionMatcher.group('major')) |
| 59 | + assignEnvVariable('BUILD_MINOR', versionMatcher.group('minor')) |
| 60 | + assignEnvVariable('BUILD_SERVICE', versionMatcher.group('service')) |
| 61 | + versionMatcher = null // release matcher as it's not serializable |
| 62 | + |
| 63 | + if ("${CHECKPOINT}" ==~ /M\d+([a-z])?/ || "${CHECKPOINT}" ==~ /RC\d+([a-z])?/) { // milestone or RC promotion |
| 64 | + assignEnvVariable('DL_TYPE', 'S') |
| 65 | + // REPO_SITE_SEGMENT variale not used in this case |
| 66 | + } else if(!"${CHECKPOINT}") { // release promotion |
| 67 | + assignEnvVariable('DL_TYPE', 'R') |
| 68 | + assignEnvVariable('REPO_SITE_SEGMENT', "${BUILD_MAJOR}.${BUILD_MINOR}") |
| 69 | + } else { |
| 70 | + error "CHECKPOINT, ${CHECKPOINT}, did not match any expected pattern." |
| 71 | + } |
| 72 | + assignEnvVariable('NEWS_ID', "${BUILD_MAJOR}.${BUILD_MINOR}") |
| 73 | + |
| 74 | + assignEnvVariable('DL_LABEL', "${BUILD_SERVICE}" == '0' // For initial releases, do not include service in label |
| 75 | + ? "${BUILD_MAJOR}.${BUILD_MINOR}${CHECKPOINT}" |
| 76 | + : "${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_SERVICE}${CHECKPOINT}" |
| 77 | + ) |
| 78 | + assignEnvVariable('DL_LABEL_EQ', "${DL_LABEL}") |
| 79 | + |
| 80 | + // This is DL_DROP_ID for Eclipse. The one for equinox has DL_LABEL_EQ in middle. |
| 81 | + assignEnvVariable('DL_DROP_ID', "${DL_TYPE}-${DL_LABEL}-${BUILD_TIMESTAMP}") |
| 82 | + assignEnvVariable('DL_DROP_ID_EQ', "${DL_TYPE}-${DL_LABEL_EQ}-${BUILD_TIMESTAMP}") |
| 83 | + |
| 84 | + if (!env.SIGNOFF_BUG) { |
| 85 | + echo '''\ |
| 86 | + [WARNING] SIGNOFF_BUG was not defined. That is valid if no Unit Tests failures but otherwise should be defined. |
| 87 | + Can be added by hand to buildproperties.php in drop site, if in fact there were errors, and simply forgot to specify. |
| 88 | + '''.stripIndent() |
| 89 | + } |
| 90 | + |
| 91 | + def serviceVersionSegment = (env.CHECKPOINT || env.BUILD_SERVICE != '0') ? ('_' + env.BUILD_SERVICE) : '' |
| 92 | + assignEnvVariable('TAG', "${DL_TYPE}${BUILD_MAJOR}_${BUILD_MINOR}${serviceVersionSegment}${env.CHECKPOINT ? ('_' + env.CHECKPOINT) : ''}") |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + stage('Rename and Promote') { |
| 97 | + environment { |
| 98 | + BUILDMACHINE_BASE_DL = "${EP_ECLIPSE_ROOT}/downloads/drops4" |
| 99 | + BUILDMACHINE_BASE_EQ = "${EP_EQUINOX_ROOT}/drops" |
| 100 | + BUILD_REPO_ORIGINAL = "${BUILD_MAJOR}.${BUILD_MINOR}-${REPO_BUILD_TYPE}-builds" |
| 101 | + BUILDMACHINE_BASE_SITE = "${EP_ECLIPSE_ROOT}/updates/${BUILD_REPO_ORIGINAL}" |
| 102 | + // Eclipse and Equinox drop Site (final segment) |
| 103 | + ECLIPSE_DL_DROP_DIR_SEGMENT = "${DL_TYPE}-${DL_LABEL}-${BUILD_TIMESTAMP}" |
| 104 | + EQUINOX_DL_DROP_DIR_SEGMENT = "${DL_TYPE}-${DL_LABEL_EQ}-${BUILD_TIMESTAMP}" |
| 105 | + } |
| 106 | + steps { |
| 107 | + writeFile(file: "${WORKSPACE}/stage2output${TRAIN_NAME}${CHECKPOINT}/mailtemplate.txt", text: """\ |
| 108 | + We are pleased to announce that ${TRAIN_NAME} ${CHECKPOINT} is available for download and updates. |
| 109 | + |
| 110 | + Eclipse downloads: |
| 111 | + https://download.eclipse.org/eclipse/downloads/drops4/${ECLIPSE_DL_DROP_DIR_SEGMENT}/ |
| 112 | + |
| 113 | + New and Noteworthy: |
| 114 | + https://www.eclipse.org/eclipse/news/${NEWS_ID}/ |
| 115 | + |
| 116 | + Update existing (non-production) installs: |
| 117 | + https://download.eclipse.org/eclipse/updates/${DL_TYPE == 'R' ? REPO_SITE_SEGMENT : BUILD_REPO_ORIGINAL}/ |
| 118 | + |
| 119 | + Specific repository good for building against: |
| 120 | + https://download.eclipse.org/eclipse/updates/${DL_TYPE == 'R' ? (REPO_SITE_SEGMENT + '/' + ECLIPSE_DL_DROP_DIR_SEGMENT) : (BUILD_REPO_ORIGINAL + '/' + DROP_ID)}/ |
| 121 | + |
| 122 | + Equinox specific downloads: |
| 123 | + https://download.eclipse.org/equinox/drops/${EQUINOX_DL_DROP_DIR_SEGMENT}/ |
| 124 | + |
| 125 | + Thank you to everyone who made this checkpoint possible. |
| 126 | + """.stripIndent()) |
| 127 | + sshagent(['projects-storage.eclipse.org-bot-ssh']) { |
| 128 | + sh '''#!/bin/bash -x |
| 129 | + curl -o promoteSites.sh https://download.eclipse.org/eclipse/relengScripts/cje-production/promotion/promoteSites.sh |
| 130 | + chmod +x promoteSites.sh |
| 131 | + ./promoteSites.sh |
| 132 | + ''' |
| 133 | + } |
| 134 | + build job: 'Releng/tagEclipseRelease', wait: true, propagate: true, parameters: [ |
| 135 | + string(name: 'tag', value: "${TAG}"), |
| 136 | + string(name: 'buildID', value: "${DROP_ID}"), |
| 137 | + string(name: 'annotation', value: "${ params.SIGNOFF_BUG ? 'https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/' + params.SIGNOFF_BUG : '' }") |
| 138 | + ] |
| 139 | + } |
| 140 | + } |
| 141 | + } |
| 142 | + post { |
| 143 | + always { |
| 144 | + archiveArtifacts '**/stage2output*/**' |
| 145 | + } |
| 146 | + } |
| 147 | +} |
| 148 | + |
| 149 | +@NonCPS |
| 150 | +def assignEnvVariable(String name, String value) { |
| 151 | + env."${name}" = value |
| 152 | + println("${name}=${value}") |
| 153 | +} |
| 154 | + |
| 155 | +@NonCPS |
| 156 | +def readParameter(String name) { |
| 157 | + //TODO: let jenkins trim the parameters |
| 158 | + def value = (params[name] ?: '').trim() |
| 159 | + if (value) { |
| 160 | + println("${name}: ${value}") |
| 161 | + } |
| 162 | + return value |
| 163 | +} |
0 commit comments