Jessica Wagantall | d9c235c | 2018-03-21 13:03:59 -0700 | [diff] [blame] | 1 | --- |
| 2 | ########### |
| 3 | # ANCHORS # |
| 4 | ########### |
| 5 | - docker_job_boiler_plate: &docker_job_boiler_plate |
| 6 | name: docker_job_boiler_plate |
| 7 | |
| 8 | project-type: freestyle |
| 9 | node: '{build-node}' |
| 10 | |
| 11 | ###################### |
| 12 | # Default parameters # |
| 13 | ###################### |
| 14 | |
| 15 | branch: master |
| 16 | submodule-recursive: true |
| 17 | |
| 18 | # default params for docker jobs |
| 19 | pre_build_script: '' |
| 20 | post_build_script: '' |
| 21 | docker_root: '$WORKSPACE' |
| 22 | docker_build_args: '' |
| 23 | docker_name: 'unnamed' |
| 24 | # Default to LF standard 'snapshots' docker registry |
| 25 | docker_registry: '$DOCKER_REGISTRY:10003' |
| 26 | docker_tag: 'latest' |
Jessica Wagantall | 11a31f0 | 2019-05-13 12:28:14 -0700 | [diff] [blame] | 27 | submodule-disable: false |
Jessica Wagantall | 7d10bdf | 2018-10-29 11:17:16 -0700 | [diff] [blame] | 28 | submodule-timeout: 10 |
Jessica Wagantall | d9c235c | 2018-03-21 13:03:59 -0700 | [diff] [blame] | 29 | |
| 30 | ##################### |
| 31 | # Job Configuration # |
| 32 | ##################### |
| 33 | |
| 34 | properties: |
| 35 | - lf-infra-properties: |
| 36 | build-days-to-keep: '{build-days-to-keep}' |
| 37 | |
| 38 | parameters: |
| 39 | - lf-infra-parameters: |
| 40 | branch: '{branch}' |
| 41 | project: '{project}' |
| 42 | stream: '{stream}' |
| 43 | lftools-version: '{lftools-version}' |
| 44 | |
| 45 | wrappers: |
| 46 | - lf-infra-wrappers: |
| 47 | build-timeout: '{build-timeout}' |
| 48 | jenkins-ssh-credential: '{jenkins-ssh-credential}' |
| 49 | |
| 50 | publishers: |
| 51 | - lf-infra-publish |
| 52 | |
| 53 | - docker_verify_boiler_plate: &docker_verify_boiler_plate |
| 54 | name: docker_verify_boiler_plate |
| 55 | |
| 56 | concurrent: true |
| 57 | |
| 58 | scm: |
| 59 | - gerrit-trigger-scm: |
| 60 | refspec: '$GERRIT_REFSPEC' |
| 61 | choosing-strategy: 'default' |
| 62 | submodule-recursive: '{submodule-recursive}' |
| 63 | |
| 64 | triggers: |
| 65 | - gerrit-trigger-patch-submitted: |
| 66 | status-context: '{project}-Docker-Verify' |
| 67 | server: '{server-name}' |
| 68 | project: '{project}' |
| 69 | branch: '{branch}' |
Jessica Wagantall | 86d80f7 | 2018-04-03 13:34:08 -0700 | [diff] [blame] | 70 | files: '{files}' |
Jessica Wagantall | d9c235c | 2018-03-21 13:03:59 -0700 | [diff] [blame] | 71 | |
| 72 | - docker_merge_boiler_plate: &docker_merge_boiler_plate |
| 73 | name: docker_merge_boiler_plate |
| 74 | |
| 75 | scm: |
| 76 | - gerrit-trigger-scm: |
| 77 | refspec: '$GERRIT_REFSPEC' |
| 78 | choosing-strategy: 'default' |
| 79 | submodule-recursive: '{submodule-recursive}' |
| 80 | |
| 81 | triggers: |
| 82 | - gerrit-trigger-patch-merged: |
| 83 | server: '{server-name}' |
| 84 | project: '{project}' |
| 85 | branch: '{branch}' |
Jessica Wagantall | 86d80f7 | 2018-04-03 13:34:08 -0700 | [diff] [blame] | 86 | files: '{files}' |
Jessica Wagantall | d9c235c | 2018-03-21 13:03:59 -0700 | [diff] [blame] | 87 | - pollscm: |
| 88 | cron: '' |
| 89 | |
| 90 | ################# |
| 91 | # JOB TEMPLATES # |
| 92 | ################# |
| 93 | - job-template: |
| 94 | name: '{project-name}-{stream}-merge-docker' |
| 95 | # Job template for Docker merge jobs |
| 96 | # |
| 97 | # The purpose of this job template is to run a docker build, and potentially |
| 98 | # test validation of the docker image |
| 99 | |
| 100 | <<: *docker_job_boiler_plate |
| 101 | # yamllint disable-line rule:key-duplicates |
| 102 | <<: *docker_merge_boiler_plate |
| 103 | |
| 104 | builders: |
Jessica Wagantall | 05ae7da | 2018-10-22 17:32:33 -0700 | [diff] [blame] | 105 | - lf-infra-pre-build |
Jessica Wagantall | d9c235c | 2018-03-21 13:03:59 -0700 | [diff] [blame] | 106 | - lf-infra-docker-login: |
| 107 | global-settings-file: 'global-settings' |
| 108 | settings-file: '{mvn-settings}' |
| 109 | - shell: '{pre_build_script}' |
| 110 | - inject: |
| 111 | # Docker registry is purposely not using an '_' so as to not conflict |
| 112 | # with the Jenkins global env var |
| 113 | properties-content: | |
| 114 | DOCKER_ARGS={docker_build_args} |
| 115 | DOCKER_NAME={docker_name} |
| 116 | DOCKER_ROOT={docker_root} |
| 117 | DOCKER_TAG={docker_tag} |
Denes Nemeth | bb2815b | 2018-05-15 22:12:54 +0200 | [diff] [blame] | 118 | BUILD_MODE=SNAPSHOT |
Jessica Wagantall | d9c235c | 2018-03-21 13:03:59 -0700 | [diff] [blame] | 119 | DOCKERREGISTRY={docker_registry} |
| 120 | # Do the docker build |
| 121 | - shell: !include-raw: ../shell/docker-build.sh |
| 122 | - inject: |
| 123 | # Import the docker image information from the build step |
| 124 | properties-file: 'env_inject.txt' |
| 125 | # Execute any post build clean-up or testing |
| 126 | - shell: '{post_build_script}' |
| 127 | # Provided all steps have already passed, push the docker image |
| 128 | - shell: !include-raw: ../shell/docker-push.sh |
| 129 | |
| 130 | - job-template: |
| 131 | name: '{project-name}-{stream}-verify-docker' |
| 132 | # Job template for Docker verify jobs |
| 133 | # |
| 134 | # The purpose of this job template is to run a docker build, and potentially |
| 135 | # test validation of the docker image |
| 136 | |
| 137 | ###################### |
| 138 | # Default parameters # |
| 139 | ###################### |
| 140 | |
| 141 | <<: *docker_job_boiler_plate |
| 142 | # yamllint disable-line rule:key-duplicates |
| 143 | <<: *docker_verify_boiler_plate |
| 144 | |
| 145 | builders: |
Jessica Wagantall | 05ae7da | 2018-10-22 17:32:33 -0700 | [diff] [blame] | 146 | - lf-infra-pre-build |
Jessica Wagantall | d9c235c | 2018-03-21 13:03:59 -0700 | [diff] [blame] | 147 | - lf-infra-docker-login: |
| 148 | global-settings-file: 'global-settings' |
| 149 | settings-file: '{mvn-settings}' |
| 150 | - shell: '{pre_build_script}' |
| 151 | - inject: |
| 152 | # Docker registry is purposely not using an '_' so as to not conflict |
| 153 | # with the Jenkins global env var |
| 154 | properties-content: | |
| 155 | DOCKER_ARGS={docker_build_args} |
| 156 | DOCKER_NAME={docker_name} |
| 157 | DOCKER_ROOT={docker_root} |
| 158 | DOCKER_TAG={docker_tag} |
Denes Nemeth | bb2815b | 2018-05-15 22:12:54 +0200 | [diff] [blame] | 159 | BUILD_MODE=SNAPSHOT |
Jessica Wagantall | d9c235c | 2018-03-21 13:03:59 -0700 | [diff] [blame] | 160 | DOCKERREGISTRY={docker_registry} |
| 161 | # Do the docker build |
| 162 | - shell: !include-raw: ../shell/docker-build.sh |
| 163 | - inject: |
| 164 | # Import the docker image information from the build step |
| 165 | properties-file: 'env_inject.txt' |
| 166 | # Execute any post build clean-up or testing |
| 167 | - shell: '{post_build_script}' |
| 168 | |
| 169 | - job-template: |
Bengt Thuree | 1515daa | 2019-09-10 13:39:04 +0200 | [diff] [blame] | 170 | # Job template for creating a docker manifest list |
| 171 | # |
| 172 | # The purpose of this job template is to run: |
| 173 | # 1. docker_push_manifest.sh script (which needs to exist in the |
| 174 | # project implementation repo) |
Denes Nemeth | 88405ef | 2018-06-19 14:21:59 +0800 | [diff] [blame] | 175 | |
Bengt Thuree | 1515daa | 2019-09-10 13:39:04 +0200 | [diff] [blame] | 176 | name: '{project-name}-docker-manifest-{stream}' |
| 177 | <<: *docker_job_boiler_plate |
| 178 | node: '{build-node}' |
| 179 | build-timeout: 15 |
| 180 | |
| 181 | parameters: |
| 182 | - lf-infra-parameters: |
| 183 | project: '{project}' |
| 184 | stream: '{stream}' |
| 185 | branch: '{branch}' |
| 186 | - string: |
| 187 | name: PARENT_JOB_NAME |
| 188 | default: 'none' |
| 189 | |
| 190 | disabled: '{obj:disabled}' |
| 191 | |
| 192 | scm: |
| 193 | - lf-infra-gerrit-scm: |
| 194 | jenkins-ssh-credential: '{jenkins-ssh-credential}' |
| 195 | git-url: '$GIT_URL/$PROJECT' |
| 196 | refspec: '$GERRIT_REFSPEC' |
| 197 | branch: '$GERRIT_BRANCH' |
| 198 | submodule-recursive: true |
| 199 | submodule-disable: '{submodule-disable}' |
| 200 | submodule-timeout: '{submodule-timeout}' |
| 201 | choosing-strategy: default |
| 202 | |
| 203 | |
| 204 | builders: |
| 205 | - lf-infra-docker-login: |
| 206 | global-settings-file: 'global-settings' |
| 207 | settings-file: '{mvn-settings}' |
| 208 | - shell: | |
| 209 | #!/bin/bash -ex |
| 210 | export PARENT_JOB_NAME |
| 211 | ./docker_push_manifest.sh |
| 212 | |
| 213 | - job-template: |
| 214 | # Job template for staging jobs on multiple architectures |
| 215 | # |
| 216 | # The purpose of this job template is to: |
| 217 | # 1. Run parallel maven-docker-stage jobs for each supported architecure |
| 218 | # 2. Build and push a docker manifest list for the images created by |
| 219 | # the previous jobs |
| 220 | |
| 221 | name: '{project-name}-multiarch-docker-stage-{stream}' |
| 222 | node: '{build-node}' |
| 223 | project-type: multijob |
| 224 | disabled: '{obj:disabled}' |
| 225 | build-timeout: 15 |
| 226 | pattern: '**' |
| 227 | |
| 228 | parameters: |
| 229 | - lf-infra-parameters: |
| 230 | project: '{project}' |
| 231 | stream: '{stream}' |
| 232 | branch: '{branch}' |
| 233 | - string: |
| 234 | name: DOCKER_REGISTRY |
| 235 | default: 'none' |
| 236 | - string: |
| 237 | name: DOCKERHUB_REGISTRY |
| 238 | default: 'registry-1.docker.io' |
| 239 | |
| 240 | disabled: '{obj:disabled}' |
| 241 | |
| 242 | properties: |
| 243 | - throttle: |
| 244 | max-per-node: 1 |
| 245 | option: 'project' |
| 246 | - build-blocker: |
| 247 | use-build-blocker: true |
| 248 | blocking-jobs: |
| 249 | - '{project-name}-.*-docker-.*' |
| 250 | blocking-level: 'NODE' |
| 251 | |
| 252 | scm: |
| 253 | - lf-infra-gerrit-scm: |
| 254 | jenkins-ssh-credential: '{jenkins-ssh-credential}' |
| 255 | git-url: '$GIT_URL/$PROJECT' |
| 256 | refspec: '$GERRIT_REFSPEC' |
| 257 | branch: '$GERRIT_BRANCH' |
| 258 | submodule-recursive: true |
| 259 | submodule-timeout: 10 |
| 260 | submodule-disable: false |
| 261 | choosing-strategy: default |
| 262 | |
| 263 | triggers: |
| 264 | - timed: '@daily' |
| 265 | - gerrit: |
| 266 | server-name: '{gerrit-server-name}' |
| 267 | trigger-on: |
| 268 | - comment-added-contains-event: |
| 269 | comment-contains-value: '^Patch Set\s+\d+:\s+stage-(docker-)?release\s*$' |
| 270 | |
| 271 | projects: |
| 272 | - project-compare-type: ANT |
| 273 | project-pattern: '{project}' |
| 274 | branches: |
| 275 | - branch-compare-type: ANT |
| 276 | branch-pattern: '**/{branch}' |
| 277 | file-paths: |
| 278 | - compare-type: ANT |
| 279 | pattern: "**" |
| 280 | |
| 281 | builders: |
| 282 | - multijob: |
| 283 | name: 'build docker images' |
| 284 | condition: ALWAYS |
| 285 | execution-type: PARALLEL |
| 286 | projects: |
| 287 | - name: '{project-name}-amd64-maven-docker-stage-{stream}' |
| 288 | kill-phase-on: FAILURE |
| 289 | current-parameters: true |
| 290 | - name: '{project-name}-arm64-maven-docker-stage-{stream}' |
| 291 | kill-phase-on: NEVER |
| 292 | current-parameters: true |
| 293 | - multijob: |
| 294 | name: 'publish docker manifest' |
| 295 | condition: SUCCESSFUL |
| 296 | execution-type: PARALLEL |
| 297 | projects: |
| 298 | - name: '{project-name}-docker-manifest-{stream}' |
| 299 | current-parameters: true |
| 300 | predefined-parameters: | |
| 301 | PARENT_JOB_NAME=$JOB_NAME |
| 302 | DOCKERHUB_REGISTRY=docker.io |