|
| 1 | +/* HWCPipe basic pipeline framework |
| 2 | + */ |
| 3 | + |
| 4 | +final Map K8S_CONFIG = [ |
| 5 | + registry: 'mobile-studio--docker.eu-west-1.artifactory.aws.arm.com', |
| 6 | + registryCredentials: 'artifactory-ms-docker', |
| 7 | + imageName: 'hwcpipe', |
| 8 | + imageTag: '1.0.0' |
| 9 | +] |
| 10 | + |
| 11 | +/** |
| 12 | + @brief Return Kubernetes pod definition |
| 13 | + */ |
| 14 | +@NonCPS |
| 15 | +def getPodTemplate(Map K8S_CONFIG, String containerName) { |
| 16 | + return """ |
| 17 | +apiVersion: v1 |
| 18 | +kind: Pod |
| 19 | +spec: |
| 20 | + imagePullSecrets: |
| 21 | + - name: ${K8S_CONFIG.registryCredentials} |
| 22 | + securityContext: |
| 23 | + runAsUser: 1000 |
| 24 | + runAsGroup: 1000 |
| 25 | + containers: |
| 26 | + - name: ${containerName} |
| 27 | + image: ${K8S_CONFIG.registry}/${K8S_CONFIG.imageName}:${K8S_CONFIG.imageTag} |
| 28 | + command: |
| 29 | + - sleep |
| 30 | + args: |
| 31 | + - infinity |
| 32 | + resources: |
| 33 | + requests: |
| 34 | + cpu: 4 |
| 35 | + memory: 8Gi |
| 36 | + limits: |
| 37 | + cpu: 8 |
| 38 | + memory: 16Gi |
| 39 | +""" |
| 40 | +} |
| 41 | + |
| 42 | +pipeline { |
| 43 | + agent none |
| 44 | + |
| 45 | + options { |
| 46 | + ansiColor('xterm') |
| 47 | + timestamps() |
| 48 | + } |
| 49 | + |
| 50 | + stages { |
| 51 | + stage('Build All') { |
| 52 | + parallel { |
| 53 | + /* Build for Linux on Ubuntu 20.04 x86-64 */ |
| 54 | + stage('Linux') { |
| 55 | + agent { |
| 56 | + kubernetes { |
| 57 | + yaml getPodTemplate(K8S_CONFIG, 'hwcpipe-build') |
| 58 | + defaultContainer 'hwcpipe-build' |
| 59 | + } |
| 60 | + } |
| 61 | + stages { |
| 62 | + stage('Build') { |
| 63 | + steps { |
| 64 | + sh ''' |
| 65 | + echo "Look at me Ma! I'm building on Ubuntu 20.04!" |
| 66 | + ''' |
| 67 | + } |
| 68 | + } |
| 69 | + stage('Stash') { |
| 70 | + steps { |
| 71 | + sh ''' |
| 72 | + echo "Look at me Ma! I'm stashing artefacts on Ubuntu 20.04!" |
| 73 | + ''' |
| 74 | + } |
| 75 | + } |
| 76 | + stage('Test') { |
| 77 | + steps { |
| 78 | + sh ''' |
| 79 | + echo "Look at me Ma! I'm testing on Ubuntu 20.04!" |
| 80 | + ''' |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + /* Build for Windows on x86-64 */ |
| 86 | + stage('Windows') { |
| 87 | + agent { |
| 88 | + label 'Windows' |
| 89 | + } |
| 90 | + stages { |
| 91 | + stage('Clean') { |
| 92 | + steps { |
| 93 | + bat 'git clean -ffdx' |
| 94 | + } |
| 95 | + } |
| 96 | + stage('Build') { |
| 97 | + steps { |
| 98 | + bat ''' |
| 99 | + echo "Look at me Ma! I'm building on Windows!" |
| 100 | + ''' |
| 101 | + } |
| 102 | + } |
| 103 | + stage('Stash') { |
| 104 | + steps { |
| 105 | + bat ''' |
| 106 | + echo "Look at me Ma! I'm stashing artefacts on Windows" |
| 107 | + ''' |
| 108 | + } |
| 109 | + } |
| 110 | + stage('Test') { |
| 111 | + steps { |
| 112 | + bat ''' |
| 113 | + echo "Look at me Ma! I'm testing on Windows!" |
| 114 | + ''' |
| 115 | + } |
| 116 | + } |
| 117 | + } |
| 118 | + } |
| 119 | + /* Build for macOS on x86-64 */ |
| 120 | + stage('macOS x86') { |
| 121 | + agent { |
| 122 | + label 'mac' |
| 123 | + } |
| 124 | + stages { |
| 125 | + stage('Clean') { |
| 126 | + steps { |
| 127 | + sh 'git clean -ffdx' |
| 128 | + } |
| 129 | + } |
| 130 | + stage('Build') { |
| 131 | + steps { |
| 132 | + sh ''' |
| 133 | + echo "Look at me Ma! I'm building on Mac x86" |
| 134 | + ''' |
| 135 | + } |
| 136 | + } |
| 137 | + stage('Stash') { |
| 138 | + steps { |
| 139 | + sh ''' |
| 140 | + echo "Look at me Ma! I'm stashing artefacts on Mac x86" |
| 141 | + ''' |
| 142 | + } |
| 143 | + } |
| 144 | + stage('Test') { |
| 145 | + steps { |
| 146 | + sh ''' |
| 147 | + echo "Look at me Ma! I'm testing on Mac x86" |
| 148 | + ''' |
| 149 | + } |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + /* Build for macOS on Apple M1 */ |
| 154 | + stage('macOS M1') { |
| 155 | + agent { |
| 156 | + label 'macm1' |
| 157 | + } |
| 158 | + stages { |
| 159 | + stage('Clean') { |
| 160 | + steps { |
| 161 | + sh 'git clean -ffdx' |
| 162 | + } |
| 163 | + } |
| 164 | + stage('Build') { |
| 165 | + steps { |
| 166 | + sh ''' |
| 167 | + echo "Look at me Ma! I'm building on Mac M1" |
| 168 | + ''' |
| 169 | + } |
| 170 | + } |
| 171 | + stage('Stash') { |
| 172 | + steps { |
| 173 | + sh ''' |
| 174 | + echo "Look at me Ma! I'm stashing artefacts on Mac M1" |
| 175 | + ''' |
| 176 | + } |
| 177 | + } |
| 178 | + stage('Test') { |
| 179 | + steps { |
| 180 | + sh ''' |
| 181 | + echo "Look at me Ma! I'm testing on Mac M1" |
| 182 | + ''' |
| 183 | + } |
| 184 | + } |
| 185 | + } |
| 186 | + } |
| 187 | + } |
| 188 | + } |
| 189 | + stage('Artifactory') { |
| 190 | + agent { |
| 191 | + kubernetes { |
| 192 | + yaml getPodTemplate(K8S_CONFIG, 'hwcpipe-af') |
| 193 | + defaultContainer 'hwcpipe-af' |
| 194 | + } |
| 195 | + } |
| 196 | + options { |
| 197 | + skipDefaultCheckout true |
| 198 | + } |
| 199 | + stages { |
| 200 | + stage('Unstash') { |
| 201 | + steps { |
| 202 | + sh ''' |
| 203 | + echo "Unstashing" |
| 204 | + ''' |
| 205 | + } |
| 206 | + } |
| 207 | + stage('Upload') { |
| 208 | + steps { |
| 209 | + echo 'Uploading to AF' |
| 210 | + // zip zipFile: 'hwcpipe.zip', dir: 'upload', archive: false |
| 211 | + // cepeArtifactoryUpload(sourcePattern: 'hwcpipe.zip') |
| 212 | + } |
| 213 | + } |
| 214 | + } |
| 215 | + } |
| 216 | + } |
| 217 | +} |
0 commit comments