Lott, Christopher (cl778h) | 868ab36 | 2019-07-31 15:32:03 -0400 | [diff] [blame] | 1 | --- |
| 2 | # Copyright (c) 2019 AT&T Intellectual Property. |
| 3 | # Copyright (c) 2019 Nokia. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Macros and templates for using Docker as the CI system. |
| 18 | # The merge template calls builders to build in docker, |
| 19 | # export files, then push to PackageCloud. |
| 20 | # The docker image is discarded, not pushed to a registry. |
| 21 | # Uses builders defined in, and mirrors the structure of, |
| 22 | # global-jjb resource jjb/lf-docker-jobs.yaml |
| 23 | |
| 24 | - builder: |
| 25 | name: oran-packagecloud-file-provider |
| 26 | builders: |
| 27 | - config-file-provider: |
| 28 | files: |
| 29 | - file-id: ".packagecloud" |
| 30 | target: "$HOME/.packagecloud" |
| 31 | - config-file-provider: |
| 32 | files: |
| 33 | - file-id: "packagecloud_api" |
| 34 | target: "$HOME/packagecloud_api" |
| 35 | |
| 36 | # This shell script launches the container, which copies |
| 37 | # build products to a mounted volume. Script needs vars |
| 38 | # CONTAINER_PUSH_REGISTRY, DOCKER_NAME and DOCKER_IMAGE_TAG |
| 39 | # as set by lf-docker-get-container-tag and lf-docker-build. |
| 40 | - builder: |
| 41 | name: oran-docker-build-export |
| 42 | builders: |
| 43 | - shell: !include-raw-escape: |
| 44 | - shell/export-packages.sh |
| 45 | |
| 46 | - builder: |
| 47 | # {packagecloud-account} is PackageCloud account ID; example: oran |
| 48 | # {packagecloud-repo} is PackageCloud repository; example: master, staging |
| 49 | # {debian-distribution-versions} is list of DEB package distro/version strings |
| 50 | # separated by space; example: ubuntu/bionic debian/stretch |
| 51 | # {rpm-distribution-versions} is list of RPM package distro/version strings |
| 52 | # separated by space; example: el/4 el/5 |
| 53 | name: oran-packagecloud-push |
| 54 | builders: |
| 55 | - inject: |
| 56 | properties-content: | |
| 57 | PACKAGECLOUD_ACCOUNT={packagecloud-account} |
| 58 | PACKAGECLOUD_REPO={packagecloud-repo} |
| 59 | DEBIAN_DISTRIBUTION_VERSIONS={debian-distribution-versions} |
| 60 | RPM_DISTRIBUTION_VERSIONS={rpm-distribution-versions} |
| 61 | - shell: !include-raw-escape: |
| 62 | - shell/packagecloud-push.sh |
| 63 | |
| 64 | # Different name, same content as lf_docker_common |
| 65 | - oran_docker_common: &oran_docker_common |
| 66 | name: oran-docker-ci-common |
| 67 | |
| 68 | project-type: freestyle |
| 69 | node: "{build-node}" |
| 70 | |
| 71 | ###################### |
| 72 | # Default parameters # |
| 73 | ###################### |
| 74 | |
| 75 | branch: master |
| 76 | build-days-to-keep: 7 |
| 77 | build-timeout: 60 |
| 78 | submodule-disable: false |
| 79 | submodule-recursive: true |
| 80 | submodule-timeout: 10 |
| 81 | pre_docker_build_script: "# pre docker build script goes here" |
| 82 | post_docker_build_script: "# post docker build script goes here" |
| 83 | disable-job: "false" |
Houa Yang | 4473b93 | 2019-11-22 15:34:48 -0600 | [diff] [blame^] | 84 | docker-get-container-tag-script: "../shell/docker-get-container-tag.sh" |
Lott, Christopher (cl778h) | 868ab36 | 2019-07-31 15:32:03 -0400 | [diff] [blame] | 85 | docker-root: "$WORKSPACE" |
| 86 | docker-build-args: "" |
| 87 | git-url: "$GIT_URL/$PROJECT" |
| 88 | # TODO: how to interpolate value of {docker-root} parameter? |
| 89 | container-tag-yaml-dir: "" |
| 90 | |
| 91 | ##################### |
| 92 | # Job Configuration # |
| 93 | ##################### |
| 94 | |
| 95 | disabled: "{disable-job}" |
| 96 | |
| 97 | properties: |
| 98 | - lf-infra-properties: |
| 99 | build-days-to-keep: "{build-days-to-keep}" |
| 100 | |
| 101 | parameters: |
| 102 | - lf-infra-parameters: |
| 103 | branch: "{branch}" |
| 104 | project: "{project}" |
| 105 | refspec: "refs/heads/{branch}" |
| 106 | stream: "{stream}" |
| 107 | |
| 108 | wrappers: |
| 109 | - lf-infra-wrappers: |
| 110 | build-timeout: "{build-timeout}" |
| 111 | jenkins-ssh-credential: "{jenkins-ssh-credential}" |
| 112 | |
| 113 | publishers: |
| 114 | - lf-infra-publish |
| 115 | |
| 116 | - oran_docker_ci_pc_merge_common: &oran_docker_ci_pc_merge_common |
| 117 | name: oran-docker-ci-pc-merge-common |
| 118 | cron: "" |
| 119 | |
| 120 | scm: |
| 121 | - lf-infra-gerrit-scm: |
| 122 | jenkins-ssh-credential: "{jenkins-ssh-credential}" |
| 123 | git-url: "{git-url}" |
| 124 | refspec: "$GERRIT_REFSPEC" |
| 125 | branch: "$GERRIT_BRANCH" |
| 126 | submodule-disable: "{submodule-disable}" |
| 127 | submodule-recursive: "{submodule-recursive}" |
| 128 | submodule-timeout: "{submodule-timeout}" |
| 129 | choosing-strategy: gerrit |
| 130 | |
| 131 | gerrit_merge_triggers: |
| 132 | - change-merged-event |
| 133 | - comment-added-contains-event: |
| 134 | comment-contains-value: remerge$ |
| 135 | |
| 136 | gerrit_trigger_file_paths: |
| 137 | - compare-type: REG_EXP |
| 138 | pattern: ".*" |
| 139 | |
| 140 | builders: |
| 141 | - lf-infra-pre-build |
| 142 | - config-file-provider: |
| 143 | files: |
| 144 | - file-id: ".packagecloud" |
| 145 | target: "$HOME/.packagecloud" |
| 146 | - lf-infra-docker-login: |
| 147 | global-settings-file: "global-settings" |
| 148 | settings-file: "{mvn-settings}" |
| 149 | - shell: "{pre_docker_build_script}" |
| 150 | - lf-docker-get-container-tag: |
| 151 | container-tag-method: "{container-tag-method}" |
| 152 | container-tag-yaml-dir: "{container-tag-yaml-dir}" |
| 153 | docker-root: "{docker-root}" |
Houa Yang | 4473b93 | 2019-11-22 15:34:48 -0600 | [diff] [blame^] | 154 | docker-get-container-tag-script: "{docker-get-container-tag-script}" |
Lott, Christopher (cl778h) | 868ab36 | 2019-07-31 15:32:03 -0400 | [diff] [blame] | 155 | - lf-docker-build: |
| 156 | docker-build-args: "{docker-build-args}" |
| 157 | docker-name: "{docker-name}" |
| 158 | docker-root: "{docker-root}" |
| 159 | container-public-registry: "{container-public-registry}" |
| 160 | container-push-registry: "{container-push-registry}" |
| 161 | - shell: "{post_docker_build_script}" |
| 162 | - oran-docker-build-export |
| 163 | - oran-packagecloud-push: |
| 164 | packagecloud-account: "{packagecloud-account}" |
| 165 | packagecloud-repo: "{packagecloud-repo}" |
| 166 | debian-distribution-versions: "{debian-distribution-versions}" |
| 167 | rpm-distribution-versions: "{rpm-distribution-versions}" |
| 168 | - lf-provide-maven-settings-cleanup |
| 169 | |
| 170 | - job-template: |
| 171 | name: "{project-name}-docker-ci-pc-merge-{stream}" |
| 172 | id: oran-gerrit-docker-ci-pc-merge |
| 173 | |
| 174 | <<: *oran_docker_common |
| 175 | # yamllint disable-line rule:key-duplicates |
| 176 | <<: *oran_docker_ci_pc_merge_common |
| 177 | |
| 178 | triggers: |
| 179 | - timed: "{obj:cron}" |
| 180 | - gerrit: |
| 181 | server-name: "{gerrit-server-name}" |
| 182 | trigger-on: "{obj:gerrit_merge_triggers}" |
| 183 | projects: |
| 184 | - project-compare-type: ANT |
| 185 | project-pattern: "{project}" |
| 186 | branches: |
| 187 | - branch-compare-type: ANT |
| 188 | branch-pattern: "**/{branch}" |
| 189 | file-paths: "{obj:gerrit_trigger_file_paths}" |