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