blob: 68a890837e0108f6528cc1dc5c4c404679273c0c [file] [log] [blame]
Lott, Christopher (cl778h)868ab362019-07-31 15:32:03 -04001---
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"
84 docker-root: "$WORKSPACE"
85 docker-build-args: ""
86 git-url: "$GIT_URL/$PROJECT"
87 # TODO: how to interpolate value of {docker-root} parameter?
88 container-tag-yaml-dir: ""
89
90 #####################
91 # Job Configuration #
92 #####################
93
94 disabled: "{disable-job}"
95
96 properties:
97 - lf-infra-properties:
98 build-days-to-keep: "{build-days-to-keep}"
99
100 parameters:
101 - lf-infra-parameters:
102 branch: "{branch}"
103 project: "{project}"
104 refspec: "refs/heads/{branch}"
105 stream: "{stream}"
106
107 wrappers:
108 - lf-infra-wrappers:
109 build-timeout: "{build-timeout}"
110 jenkins-ssh-credential: "{jenkins-ssh-credential}"
111
112 publishers:
113 - lf-infra-publish
114
115- oran_docker_ci_pc_merge_common: &oran_docker_ci_pc_merge_common
116 name: oran-docker-ci-pc-merge-common
117 cron: ""
118
119 scm:
120 - lf-infra-gerrit-scm:
121 jenkins-ssh-credential: "{jenkins-ssh-credential}"
122 git-url: "{git-url}"
123 refspec: "$GERRIT_REFSPEC"
124 branch: "$GERRIT_BRANCH"
125 submodule-disable: "{submodule-disable}"
126 submodule-recursive: "{submodule-recursive}"
127 submodule-timeout: "{submodule-timeout}"
128 choosing-strategy: gerrit
129
130 gerrit_merge_triggers:
131 - change-merged-event
132 - comment-added-contains-event:
133 comment-contains-value: remerge$
134
135 gerrit_trigger_file_paths:
136 - compare-type: REG_EXP
137 pattern: ".*"
138
139 builders:
140 - lf-infra-pre-build
141 - config-file-provider:
142 files:
143 - file-id: ".packagecloud"
144 target: "$HOME/.packagecloud"
145 - lf-infra-docker-login:
146 global-settings-file: "global-settings"
147 settings-file: "{mvn-settings}"
148 - shell: "{pre_docker_build_script}"
149 - lf-docker-get-container-tag:
150 container-tag-method: "{container-tag-method}"
151 container-tag-yaml-dir: "{container-tag-yaml-dir}"
152 docker-root: "{docker-root}"
153 - lf-docker-build:
154 docker-build-args: "{docker-build-args}"
155 docker-name: "{docker-name}"
156 docker-root: "{docker-root}"
157 container-public-registry: "{container-public-registry}"
158 container-push-registry: "{container-push-registry}"
159 - shell: "{post_docker_build_script}"
160 - oran-docker-build-export
161 - oran-packagecloud-push:
162 packagecloud-account: "{packagecloud-account}"
163 packagecloud-repo: "{packagecloud-repo}"
164 debian-distribution-versions: "{debian-distribution-versions}"
165 rpm-distribution-versions: "{rpm-distribution-versions}"
166 - lf-provide-maven-settings-cleanup
167
168- job-template:
169 name: "{project-name}-docker-ci-pc-merge-{stream}"
170 id: oran-gerrit-docker-ci-pc-merge
171
172 <<: *oran_docker_common
173 # yamllint disable-line rule:key-duplicates
174 <<: *oran_docker_ci_pc_merge_common
175
176 triggers:
177 - timed: "{obj:cron}"
178 - gerrit:
179 server-name: "{gerrit-server-name}"
180 trigger-on: "{obj:gerrit_merge_triggers}"
181 projects:
182 - project-compare-type: ANT
183 project-pattern: "{project}"
184 branches:
185 - branch-compare-type: ANT
186 branch-pattern: "**/{branch}"
187 file-paths: "{obj:gerrit_trigger_file_paths}"