Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 1 | @Library("cmsis") |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 2 | import com.arm.dsg.cmsis.jenkins.ArtifactoryHelper |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 3 | |
| 4 | DOCKERINFO = [ |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 5 | 'staging': [ |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 6 | 'registryUrl': 'mcu--docker-staging.eu-west-1.artifactory.aws.arm.com', |
| 7 | 'registryCredentialsId': 'artifactory', |
| 8 | 'k8sPullSecret': 'artifactory-mcu-docker-staging', |
| 9 | 'namespace': 'mcu--docker-staging', |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 10 | 'image': 'cmsis/linux', |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 11 | 'label': "${JENKINS_ENV}-${JOB_BASE_NAME}-${BUILD_NUMBER}" |
| 12 | ], |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 13 | 'production': [ |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 14 | 'registryUrl': 'mcu--docker.eu-west-1.artifactory.aws.arm.com', |
| 15 | 'registryCredentialsId': 'artifactory', |
| 16 | 'namespace': 'mcu--docker', |
| 17 | 'k8sPullSecret': 'artifactory-mcu-docker', |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 18 | 'image': 'cmsis/linux', |
| 19 | 'label': 'latest' |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 20 | ] |
| 21 | ] |
Jonatan Antoni | b5d07f0 | 2021-07-14 12:50:57 +0200 | [diff] [blame] | 22 | HADOLINT_VERSION = '2.6.0-alpine' |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 23 | |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 24 | dockerinfo = DOCKERINFO['production'] |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 25 | |
| 26 | isPrecommit = (JOB_BASE_NAME == 'pre_commit') |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 27 | isPostcommit = (JOB_BASE_NAME == 'post_commit') |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 28 | isNightly = (JOB_BASE_NAME == 'nightly') |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 29 | isRelease = (JOB_BASE_NAME == 'release') |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 30 | |
Jonatan Antoni | 5f8564b | 2021-04-29 16:59:54 +0200 | [diff] [blame] | 31 | patternGlobal = [ |
| 32 | '^Jenkinsfile' |
| 33 | ] |
| 34 | |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 35 | patternDocker = [ |
| 36 | '^docker/.*' |
| 37 | ] |
| 38 | |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 39 | patternCoreM = [ |
| 40 | '^CMSIS/Core/Include/.*', |
| 41 | '^Device/ARM/ARMCM.*' |
| 42 | ] |
| 43 | |
| 44 | patternCoreA = [ |
| 45 | '^CMSIS/Core_A/Include/.*', |
| 46 | '^Device/ARM/ARMCA.*' |
| 47 | ] |
| 48 | |
| 49 | patternCoreValidation = [ |
| 50 | '^CMSIS/CoreValidation/.*' |
| 51 | ] |
| 52 | |
| 53 | CONFIGURATIONS = [ |
| 54 | 'pre_commit': [ |
Jonatan Antoni | 983aa0b | 2021-05-05 13:19:48 +0200 | [diff] [blame] | 55 | 'mdevices': ['CM0', 'CM3', 'CM4FP', 'CM7DP', 'CM23', 'CM33NS', 'CM35PS', 'CM55NS'], |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 56 | 'adevices': ['CA7', 'CA9neon'], |
| 57 | 'devices' : [], |
| 58 | 'configs' : [ |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 59 | 'AC5': ['low', 'tiny'], |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 60 | 'AC6': ['low', 'tiny'], |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 61 | 'AC6LTM': ['low', 'tiny'], |
| 62 | 'GCC': ['low', 'tiny'] |
| 63 | ] |
| 64 | ], |
| 65 | 'post_commit': [ |
| 66 | 'devices' : ['CM0', 'CM0plus', 'CM3', 'CM4', 'CM4FP', 'CM7', 'CM7SP', 'CM7DP', |
| 67 | 'CM23', 'CM23S', 'CM23NS', 'CM33', 'CM33S', 'CM33NS', |
Jonatan Antoni | 983aa0b | 2021-05-05 13:19:48 +0200 | [diff] [blame] | 68 | 'CM35P', 'CM35PS', 'CM35PNS', 'CM55', 'CM55S', 'CM55NS', |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 69 | 'CA5', 'CA5neon', 'CA7', 'CA7neon', 'CA9', 'CA9neon'], |
| 70 | 'configs' : [ |
| 71 | 'AC5': ['low', 'tiny'], |
| 72 | 'AC6': ['low', 'tiny'], |
| 73 | 'AC6LTM': ['low', 'tiny'], |
| 74 | 'GCC': ['low', 'tiny'] |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 75 | ] |
| 76 | ], |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 77 | 'nightly': [ |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 78 | 'devices' : ['CM0', 'CM0plus', 'CM3', 'CM4', 'CM4FP', 'CM7', 'CM7SP', 'CM7DP', |
| 79 | 'CM23', 'CM23S', 'CM23NS', 'CM33', 'CM33S', 'CM33NS', |
Jonatan Antoni | 983aa0b | 2021-05-05 13:19:48 +0200 | [diff] [blame] | 80 | 'CM35P', 'CM35PS', 'CM35PNS', 'CM55', 'CM55S', 'CM55NS', |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 81 | 'CA5', 'CA5neon', 'CA7', 'CA7neon', 'CA9', 'CA9neon'], |
| 82 | 'configs' : [ |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 83 | 'AC5': ['low', 'mid', 'high', 'size', 'tiny'], |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 84 | 'AC6': ['low', 'mid', 'high', 'size', 'tiny'], |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 85 | 'AC6LTM': ['low', 'mid', 'high', 'size', 'tiny'], |
| 86 | 'GCC': ['low', 'mid', 'high', 'size', 'tiny'] |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 87 | ] |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 88 | ], |
| 89 | 'release': [] |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 90 | ] |
| 91 | CONFIGURATION = CONFIGURATIONS[JOB_BASE_NAME] |
| 92 | |
| 93 | // ---- PIPELINE CODE ---- |
| 94 | |
| 95 | def getChangeset() { |
| 96 | def fileset = sh encoding: 'UTF-8', label: '', returnStdout: true, script: 'git diff --name-only HEAD~1..HEAD' |
| 97 | return fileset.split('\n') |
| 98 | } |
| 99 | |
| 100 | def fileSetMatches(fileset, patternset) { |
| 101 | return patternset.any { p -> |
| 102 | fileset.any{ f -> f ==~ p } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | FORCE_BUILD = false |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 107 | DOCKER_BUILD = isPrecommit || isPostcommit || isNightly |
| 108 | CORE_VALIDATION = isPrecommit || isPostcommit || isNightly |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 109 | COMMIT = null |
| 110 | VERSION = null |
| 111 | |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 112 | artifactory = new ArtifactoryHelper(this) |
| 113 | |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 114 | pipeline { |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 115 | agent { label 'master' } |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 116 | options { |
| 117 | timestamps() |
| 118 | timeout(time: 1, unit: 'HOURS') |
| 119 | ansiColor('xterm') |
| 120 | skipDefaultCheckout() |
| 121 | } |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 122 | environment { |
| 123 | CI_ACCOUNT = credentials('grasci') |
| 124 | ARTIFACTORY = credentials('artifactory') |
| 125 | USER = "${CI_ACCOUNT_USR}" |
| 126 | PASS = "${CI_ACCOUNT_PSW}" |
| 127 | ARTIFACTORY_API_KEY = "${ARTIFACTORY_PSW}" |
| 128 | } |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 129 | stages { |
| 130 | stage('Checkout') { |
| 131 | steps { |
| 132 | script { |
| 133 | COMMIT = checkoutScmWithRetry(3) |
| 134 | echo "COMMIT: ${COMMIT}" |
Jonatan Antoni | 744e239 | 2022-01-27 16:58:49 +0100 | [diff] [blame] | 135 | VERSION = (sh(returnStdout: true, script: 'git describe --tags --always')).trim() |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 136 | echo "VERSION: '${VERSION}'" |
| 137 | } |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 138 | |
Jonatan Antoni | b5d07f0 | 2021-07-14 12:50:57 +0200 | [diff] [blame] | 139 | stash name: 'dockerfile', includes: 'docker/**' |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 140 | } |
| 141 | } |
| 142 | |
| 143 | stage('Analyse') { |
| 144 | when { |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 145 | expression { return isPrecommit || isPostcommit } |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 146 | beforeOptions true |
| 147 | } |
| 148 | steps { |
| 149 | script { |
| 150 | def fileset = changeset |
Jonatan Antoni | 5f8564b | 2021-04-29 16:59:54 +0200 | [diff] [blame] | 151 | def hasGlobal = fileSetMatches(fileset, patternGlobal) |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 152 | def hasDocker = fileSetMatches(fileset, patternDocker) |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 153 | def hasCoreM = fileSetMatches(fileset, patternCoreM) |
| 154 | def hasCoreA = fileSetMatches(fileset, patternCoreA) |
| 155 | def hasCoreValidation = fileSetMatches(fileset, patternCoreValidation) |
| 156 | |
| 157 | echo """Change analysis: |
Jonatan Antoni | 5f8564b | 2021-04-29 16:59:54 +0200 | [diff] [blame] | 158 | - hasGlobal = ${hasGlobal} |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 159 | - hasDocker = ${hasDocker} |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 160 | - hasCoreM = ${hasCoreM} |
| 161 | - hasCoreA = ${hasCoreA} |
| 162 | - hasCoreValidation = ${hasCoreValidation} |
| 163 | """ |
| 164 | |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 165 | if (isPrecommit) { |
| 166 | if (hasGlobal || hasDocker || hasCoreM || hasCoreValidation) { |
| 167 | CONFIGURATION['devices'] += CONFIGURATION['mdevices'] |
| 168 | } |
| 169 | if (hasGlobal || hasDocker || hasCoreA || hasCoreValidation) { |
| 170 | CONFIGURATION['devices'] += CONFIGURATION['adevices'] |
| 171 | } |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 172 | } |
| 173 | |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 174 | DOCKER_BUILD &= hasDocker |
| 175 | CORE_VALIDATION &= hasGlobal || hasDocker || hasCoreM || hasCoreA || hasCoreValidation |
| 176 | |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 177 | echo """Stage schedule: |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 178 | - DOCKER_BUILD = ${DOCKER_BUILD} |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 179 | - CORE_VALIDATION = ${CORE_VALIDATION} |
| 180 | """ |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 185 | stage('Docker Lint') { |
| 186 | when { |
| 187 | expression { return DOCKER_BUILD } |
| 188 | beforeOptions true |
| 189 | } |
| 190 | agent { |
| 191 | kubernetes { |
| 192 | defaultContainer 'hadolint' |
| 193 | slaveConnectTimeout 600 |
| 194 | yaml """\ |
| 195 | apiVersion: v1 |
| 196 | kind: Pod |
| 197 | securityContext: |
| 198 | runAsUser: 1000 |
| 199 | runAsGroup: 1000 |
| 200 | spec: |
| 201 | imagePullSecrets: |
| 202 | - name: artifactory-mcu-docker |
| 203 | securityContext: |
| 204 | runAsUser: 1000 |
| 205 | runAsGroup: 1000 |
| 206 | containers: |
| 207 | - name: hadolint |
Jonatan Antoni | b5d07f0 | 2021-07-14 12:50:57 +0200 | [diff] [blame] | 208 | image: mcu--docker.eu-west-1.artifactory.aws.arm.com/hadolint/hadolint:${HADOLINT_VERSION} |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 209 | alwaysPullImage: true |
| 210 | imagePullPolicy: Always |
| 211 | command: |
| 212 | - sleep |
| 213 | args: |
| 214 | - infinity |
| 215 | resources: |
| 216 | requests: |
| 217 | cpu: 2 |
| 218 | memory: 2Gi |
| 219 | """.stripIndent() |
| 220 | } |
| 221 | } |
| 222 | steps { |
Jonatan Antoni | b5d07f0 | 2021-07-14 12:50:57 +0200 | [diff] [blame] | 223 | unstash 'dockerfile' |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 224 | |
Jonatan Antoni | b5d07f0 | 2021-07-14 12:50:57 +0200 | [diff] [blame] | 225 | sh 'hadolint --format json docker/dockerfile* | tee hadolint.log' |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 226 | |
Jonatan Antoni | b5d07f0 | 2021-07-14 12:50:57 +0200 | [diff] [blame] | 227 | recordIssues tools: [hadoLint(id: 'hadolint', pattern: 'hadolint.log')], |
| 228 | qualityGates: [[threshold: 1, type: 'DELTA', unstable: true]], |
| 229 | referenceJobName: 'nightly', ignoreQualityGate: true |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
| 233 | stage('Docker Build') { |
| 234 | when { |
| 235 | expression { return (isPrecommit || isPostcommit) && DOCKER_BUILD } |
| 236 | beforeOptions true |
| 237 | } |
| 238 | agent { |
| 239 | kubernetes { |
| 240 | defaultContainer 'docker-dind' |
| 241 | slaveConnectTimeout 600 |
| 242 | yaml """\ |
| 243 | apiVersion: v1 |
| 244 | kind: Pod |
| 245 | spec: |
| 246 | imagePullSecrets: |
| 247 | - name: artifactory-mcu-docker |
| 248 | containers: |
| 249 | - name: docker-dind |
| 250 | image: docker:dind |
| 251 | securityContext: |
| 252 | privileged: true |
| 253 | volumeMounts: |
| 254 | - name: dind-storage |
| 255 | mountPath: /var/lib/docker |
| 256 | volumes: |
| 257 | - name: dind-storage |
| 258 | emptyDir: {} |
| 259 | """.stripIndent() |
| 260 | } |
| 261 | } |
| 262 | steps { |
| 263 | sh('apk add bash curl git') |
| 264 | script { |
Jonatan Antoni | b5d07f0 | 2021-07-14 12:50:57 +0200 | [diff] [blame] | 265 | unstash 'dockerfile' |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 266 | |
Jonatan Antoni | b5d07f0 | 2021-07-14 12:50:57 +0200 | [diff] [blame] | 267 | dir('docker') { |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 268 | dockerinfo = DOCKERINFO['staging'] |
| 269 | withCredentials([sshUserPrivateKey(credentialsId: 'grasci_with_pk', |
| 270 | keyFileVariable: 'grasciPk', |
| 271 | passphraseVariable: '', |
| 272 | usernameVariable: 'grasciUsername')]) { |
| 273 | sh("GIT_SSH_COMMAND='ssh -i $grasciPk -o StrictHostKeyChecking=no' ./getDependencies.sh") |
| 274 | } |
| 275 | docker.withRegistry("https://${dockerinfo['registryUrl']}", dockerinfo['registryCredentialsId']) { |
| 276 | def image = docker.build("${dockerinfo['registryUrl']}/${dockerinfo['image']}:${dockerinfo['label']}", "--build-arg DOCKER_REGISTRY=${dockerinfo['registryUrl']} .") |
| 277 | image.push() |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | |
Jonatan Antoni | def6f80 | 2021-05-06 17:31:38 +0200 | [diff] [blame] | 284 | stage('Pack') { |
| 285 | agent { |
| 286 | kubernetes { |
| 287 | defaultContainer 'cmsis' |
| 288 | slaveConnectTimeout 600 |
| 289 | yaml """\ |
| 290 | apiVersion: v1 |
| 291 | kind: Pod |
| 292 | spec: |
| 293 | imagePullSecrets: |
| 294 | - name: ${dockerinfo['k8sPullSecret']} |
| 295 | securityContext: |
| 296 | runAsUser: 1000 |
| 297 | runAsGroup: 1000 |
| 298 | containers: |
| 299 | - name: cmsis |
| 300 | image: ${dockerinfo['registryUrl']}/${dockerinfo['image']}:${dockerinfo['label']} |
| 301 | alwaysPullImage: true |
| 302 | imagePullPolicy: Always |
| 303 | command: |
| 304 | - sleep |
| 305 | args: |
| 306 | - infinity |
| 307 | resources: |
| 308 | requests: |
| 309 | cpu: 2 |
| 310 | memory: 2Gi |
| 311 | """.stripIndent() |
| 312 | } |
| 313 | } |
| 314 | steps { |
| 315 | checkoutScmWithRetry(3) |
Jonatan Antoni | 2d17771 | 2022-04-06 17:59:41 +0200 | [diff] [blame] | 316 | sh('./CMSIS/Utilities/fetch_devtools.sh') |
Jonatan Antoni | def6f80 | 2021-05-06 17:31:38 +0200 | [diff] [blame] | 317 | sh('./CMSIS/RTOS/RTX/LIB/fetch_libs.sh') |
| 318 | sh('./CMSIS/RTOS2/RTX/Library/fetch_libs.sh') |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 319 | |
Jonatan Antoni | def6f80 | 2021-05-06 17:31:38 +0200 | [diff] [blame] | 320 | tee('doxygen.log') { |
| 321 | sh('./CMSIS/DoxyGen/gen_doc.sh') |
| 322 | } |
| 323 | sh('./CMSIS/Utilities/gen_pack.sh') |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 324 | |
Jonatan Antoni | def6f80 | 2021-05-06 17:31:38 +0200 | [diff] [blame] | 325 | archiveArtifacts artifacts: 'output/ARM.CMSIS.*.pack', allowEmptyArchive: true |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 326 | stash name: 'pack', includes: 'output/ARM.CMSIS.*.pack' |
Jonatan Antoni | def6f80 | 2021-05-06 17:31:38 +0200 | [diff] [blame] | 327 | |
| 328 | recordIssues tools: [doxygen(id: 'DOXYGEN', name: 'Doxygen', pattern: 'doxygen.log')], |
| 329 | qualityGates: [[threshold: 1, type: 'DELTA', unstable: true]], |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 330 | referenceJobName: 'nightly', ignoreQualityGate: true |
Jonatan Antoni | def6f80 | 2021-05-06 17:31:38 +0200 | [diff] [blame] | 331 | } |
| 332 | } |
| 333 | |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 334 | stage('CoreValidation') { |
| 335 | when { |
| 336 | expression { return CORE_VALIDATION } |
| 337 | beforeOptions true |
| 338 | } |
| 339 | matrix { |
| 340 | axes { |
| 341 | axis { |
| 342 | name 'DEVICE' |
| 343 | values 'CM0', 'CM0plus', 'CM3', 'CM4', 'CM4FP', 'CM7', 'CM7SP', 'CM7DP', |
| 344 | 'CM23', 'CM23S', 'CM23NS', 'CM33', 'CM33S', 'CM33NS', |
Jonatan Antoni | 983aa0b | 2021-05-05 13:19:48 +0200 | [diff] [blame] | 345 | 'CM35P', 'CM35PS', 'CM35PNS', 'CM55', 'CM55S', 'CM55NS', |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 346 | 'CA5', 'CA5neon', 'CA7', 'CA7neon', 'CA9', 'CA9neon' |
| 347 | } |
| 348 | } |
| 349 | stages { |
| 350 | stage('Test') { |
| 351 | when { |
| 352 | expression { return DEVICE in CONFIGURATION['devices'] } |
| 353 | beforeOptions true |
| 354 | } |
| 355 | agent { |
| 356 | kubernetes { |
| 357 | defaultContainer 'cmsis' |
| 358 | slaveConnectTimeout 600 |
| 359 | yaml """\ |
| 360 | apiVersion: v1 |
| 361 | kind: Pod |
| 362 | spec: |
| 363 | imagePullSecrets: |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 364 | - name: ${dockerinfo['k8sPullSecret']} |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 365 | securityContext: |
| 366 | runAsUser: 1000 |
| 367 | runAsGroup: 1000 |
| 368 | containers: |
| 369 | - name: cmsis |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 370 | image: ${dockerinfo['registryUrl']}/${dockerinfo['image']}:${dockerinfo['label']} |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 371 | alwaysPullImage: true |
| 372 | imagePullPolicy: Always |
| 373 | command: |
| 374 | - sleep |
| 375 | args: |
| 376 | - infinity |
| 377 | resources: |
| 378 | requests: |
| 379 | cpu: 2 |
| 380 | memory: 2Gi |
| 381 | """.stripIndent() |
| 382 | } |
| 383 | } |
| 384 | steps { |
| 385 | checkoutScmWithRetry(3) |
| 386 | dir('CMSIS/CoreValidation/Tests') { |
| 387 | script { |
| 388 | CONFIGURATION['configs'].each { COMPILER, OPTS -> |
| 389 | tee("CV_${COMPILER}_${DEVICE}.log") { |
| 390 | sh "python3 build.py -d ${DEVICE} -c ${COMPILER} -o ${OPTS.join(' -o ')} build run" |
| 391 | } |
| 392 | } |
| 393 | } |
| 394 | |
Jonatan Antoni | def6f80 | 2021-05-06 17:31:38 +0200 | [diff] [blame] | 395 | archiveArtifacts artifacts: 'CoreValidation_*.zip', allowEmptyArchive: true |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 396 | stash name: "CV_${DEVICE}", includes: '*.log, *.junit' |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | stage('Results') { |
Jonatan Antoni | 6d6cf13 | 2021-05-17 16:34:25 +0200 | [diff] [blame] | 405 | when { |
| 406 | expression { return CORE_VALIDATION } |
| 407 | beforeOptions true |
| 408 | } |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 409 | steps { |
| 410 | dir('results') { |
| 411 | deleteDir() |
| 412 | script { |
| 413 | CONFIGURATION['devices'].each { unstash "CV_${it}" } |
| 414 | } |
| 415 | |
Jonatan Antoni | aedfddf | 2021-05-03 18:32:14 +0200 | [diff] [blame] | 416 | recordIssues tools: [armCc(id: 'AC5', name: 'Arm Compiler 5', pattern: 'CV_AC5_*.log'), |
| 417 | clang(id: 'AC6', name: 'Arm Compiler 6', pattern: 'CV_AC6_*.log'), |
| 418 | clang(id: 'AC6LTM', name: 'Arm Compiler 6 LTM', pattern: 'CV_AC6LTM_*.log'), |
| 419 | gcc(id: 'GCC', name: 'GNU Compiler', pattern: 'CV_GCC_*.log')], |
Jonatan Antoni | 5f8564b | 2021-04-29 16:59:54 +0200 | [diff] [blame] | 420 | qualityGates: [[threshold: 1, type: 'DELTA', unstable: true]], |
| 421 | referenceJobName: 'nightly', ignoreQualityGate: true |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 422 | xunit([ |
| 423 | JUnit(pattern: 'corevalidation_*.junit', failIfNotNew: false, skipNoTestFiles: true) |
| 424 | ]) |
| 425 | } |
| 426 | |
| 427 | } |
| 428 | } |
Jonatan Antoni | 4b0ede3 | 2021-04-29 18:26:29 +0200 | [diff] [blame] | 429 | |
| 430 | stage('Docker Promote') { |
| 431 | when { |
| 432 | expression { return isPostcommit && DOCKER_BUILD } |
| 433 | beforeOptions true |
| 434 | } |
| 435 | agent { |
| 436 | kubernetes { |
| 437 | defaultContainer 'docker-dind' |
| 438 | slaveConnectTimeout 600 |
| 439 | yaml """\ |
| 440 | apiVersion: v1 |
| 441 | kind: Pod |
| 442 | spec: |
| 443 | imagePullSecrets: |
| 444 | - name: artifactory-mcu-docker |
| 445 | containers: |
| 446 | - name: docker-dind |
| 447 | image: docker:dind |
| 448 | securityContext: |
| 449 | privileged: true |
| 450 | volumeMounts: |
| 451 | - name: dind-storage |
| 452 | mountPath: /var/lib/docker |
| 453 | volumes: |
| 454 | - name: dind-storage |
| 455 | emptyDir: {} |
| 456 | """.stripIndent() |
| 457 | } |
| 458 | } |
| 459 | steps { |
| 460 | script { |
| 461 | String postCommitTag = "${dockerinfo['registryUrl']}/${dockerinfo['image']}:${dockerinfo['label']}" |
| 462 | String prodCommitTag = "${DOCKERINFO['production']['registryUrl']}/${DOCKERINFO['production']['image']}:${DOCKERINFO['production']['label']}" |
| 463 | |
| 464 | // Pull & retag Docker Staging Container to Production |
| 465 | docker.withRegistry("https://${dockerinfo['registryUrl']}", dockerinfo['registryCredentialsId']) { |
| 466 | def image = docker.image("$postCommitTag") |
| 467 | image.pull() |
| 468 | sh "docker tag $postCommitTag $prodCommitTag" |
| 469 | } |
| 470 | // Push to Docker Production |
| 471 | docker.withRegistry("https://${DOCKERINFO['production']['registryUrl']}", DOCKERINFO['production']['registryCredentialsId']) { |
| 472 | def image = docker.image("$prodCommitTag") |
| 473 | image.push() |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | } |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 478 | |
| 479 | stage('Release Promote') { |
| 480 | when { |
| 481 | expression { return isRelease } |
| 482 | beforeOptions true |
| 483 | } |
| 484 | steps { |
| 485 | unstash name: 'pack' |
| 486 | dir('output') { |
| 487 | script { |
| 488 | artifactory.upload pattern: 'ARM.CMSIS.*.pack', |
| 489 | target: "mcu.promoted/CMSIS_5/${VERSION}/", |
| 490 | props: "GIT_COMMIT=${COMMIT['GIT_COMMIT']}" |
| 491 | } |
| 492 | withCredentials([string(credentialsId: 'grasci_github', variable: 'ghtoken')]) { |
Jonatan Antoni | 546c5c4 | 2021-06-17 16:02:24 +0200 | [diff] [blame] | 493 | sh """ |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 494 | curl -XPOST \ |
| 495 | -H "Authorization:token ${ghtoken}" \ |
| 496 | -H "Content-Type:application/octet-stream" \ |
| 497 | --data-binary @ARM.CMSIS.${VERSION}.pack \ |
Jonatan Antoni | 546c5c4 | 2021-06-17 16:02:24 +0200 | [diff] [blame] | 498 | https://uploads.github.com/repos/ARM-software/CMSIS_5/releases/${VERSION}/assets?name=ARM.CMSIS.${VERSION}.pack |
| 499 | """ |
Jonatan Antoni | 6485da4 | 2021-06-17 15:23:34 +0200 | [diff] [blame] | 500 | } |
| 501 | } |
| 502 | } |
| 503 | } |
Jonatan Antoni | 107fde4 | 2021-04-29 15:18:15 +0200 | [diff] [blame] | 504 | } |
| 505 | } |