blob: 601aee1b6c2e992e35ecef7eaba4edb829df67b2 [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.
Lott, Christopher (cl778h)42453bd2020-03-25 16:33:06 -040018
Lott, Christopher (cl778h)868ab362019-07-31 15:32:03 -040019# The merge template calls builders to build in docker,
20# export files, then push to PackageCloud.
21# The docker image is discarded, not pushed to a registry.
22# Uses builders defined in, and mirrors the structure of,
23# global-jjb resource jjb/lf-docker-jobs.yaml
24
Lott, Christopher (cl778h)868ab362019-07-31 15:32:03 -040025# This shell script launches the container, which copies
26# build products to a mounted volume. Script needs vars
27# CONTAINER_PUSH_REGISTRY, DOCKER_NAME and DOCKER_IMAGE_TAG
28# as set by lf-docker-get-container-tag and lf-docker-build.
29- builder:
30 name: oran-docker-build-export
31 builders:
32 - shell: !include-raw-escape:
Lott, Christopher (cl778h)92475f72020-03-26 07:04:57 -040033 - ../shell/export-packages.sh
Lott, Christopher (cl778h)868ab362019-07-31 15:32:03 -040034
Lott, Christopher (cl778h)868ab362019-07-31 15:32:03 -040035# Different name, same content as lf_docker_common
36- oran_docker_common: &oran_docker_common
37 name: oran-docker-ci-common
38
39 project-type: freestyle
40 node: "{build-node}"
41
42 ######################
43 # Default parameters #
44 ######################
45
46 branch: master
Lott, Christopher (cl778h)2984c9e2020-01-15 10:37:25 -050047 build-days-to-keep: 30
Lott, Christopher (cl778h)868ab362019-07-31 15:32:03 -040048 build-timeout: 60
49 submodule-disable: false
50 submodule-recursive: true
51 submodule-timeout: 10
52 pre_docker_build_script: "# pre docker build script goes here"
53 post_docker_build_script: "# post docker build script goes here"
54 disable-job: "false"
Houa Yang4473b932019-11-22 15:34:48 -060055 docker-get-container-tag-script: "../shell/docker-get-container-tag.sh"
Lott, Christopher (cl778h)868ab362019-07-31 15:32:03 -040056 docker-root: "$WORKSPACE"
57 docker-build-args: ""
58 git-url: "$GIT_URL/$PROJECT"
59 # TODO: how to interpolate value of {docker-root} parameter?
60 container-tag-yaml-dir: ""
61
62 #####################
63 # Job Configuration #
64 #####################
65
66 disabled: "{disable-job}"
67
68 properties:
69 - lf-infra-properties:
70 build-days-to-keep: "{build-days-to-keep}"
71
72 parameters:
73 - lf-infra-parameters:
74 branch: "{branch}"
75 project: "{project}"
76 refspec: "refs/heads/{branch}"
77 stream: "{stream}"
78
79 wrappers:
80 - lf-infra-wrappers:
81 build-timeout: "{build-timeout}"
82 jenkins-ssh-credential: "{jenkins-ssh-credential}"
83
84 publishers:
85 - lf-infra-publish
86
87- oran_docker_ci_pc_merge_common: &oran_docker_ci_pc_merge_common
88 name: oran-docker-ci-pc-merge-common
89 cron: ""
90
91 scm:
92 - lf-infra-gerrit-scm:
93 jenkins-ssh-credential: "{jenkins-ssh-credential}"
94 git-url: "{git-url}"
95 refspec: "$GERRIT_REFSPEC"
96 branch: "$GERRIT_BRANCH"
97 submodule-disable: "{submodule-disable}"
98 submodule-recursive: "{submodule-recursive}"
99 submodule-timeout: "{submodule-timeout}"
100 choosing-strategy: gerrit
101
102 gerrit_merge_triggers:
103 - change-merged-event
104 - comment-added-contains-event:
105 comment-contains-value: remerge$
106
107 gerrit_trigger_file_paths:
108 - compare-type: REG_EXP
109 pattern: ".*"
110
111 builders:
112 - lf-infra-pre-build
113 - config-file-provider:
114 files:
115 - file-id: ".packagecloud"
116 target: "$HOME/.packagecloud"
117 - lf-infra-docker-login:
118 global-settings-file: "global-settings"
119 settings-file: "{mvn-settings}"
120 - shell: "{pre_docker_build_script}"
121 - lf-docker-get-container-tag:
122 container-tag-method: "{container-tag-method}"
123 container-tag-yaml-dir: "{container-tag-yaml-dir}"
124 docker-root: "{docker-root}"
Houa Yang4473b932019-11-22 15:34:48 -0600125 docker-get-container-tag-script: "{docker-get-container-tag-script}"
Lott, Christopher (cl778h)868ab362019-07-31 15:32:03 -0400126 - lf-docker-build:
127 docker-build-args: "{docker-build-args}"
128 docker-name: "{docker-name}"
129 docker-root: "{docker-root}"
130 container-public-registry: "{container-public-registry}"
131 container-push-registry: "{container-push-registry}"
132 - shell: "{post_docker_build_script}"
133 - oran-docker-build-export
134 - oran-packagecloud-push:
135 packagecloud-account: "{packagecloud-account}"
136 packagecloud-repo: "{packagecloud-repo}"
137 debian-distribution-versions: "{debian-distribution-versions}"
138 rpm-distribution-versions: "{rpm-distribution-versions}"
139 - lf-provide-maven-settings-cleanup
140
141- job-template:
142 name: "{project-name}-docker-ci-pc-merge-{stream}"
143 id: oran-gerrit-docker-ci-pc-merge
144
145 <<: *oran_docker_common
146 # yamllint disable-line rule:key-duplicates
147 <<: *oran_docker_ci_pc_merge_common
148
149 triggers:
150 - timed: "{obj:cron}"
151 - gerrit:
152 server-name: "{gerrit-server-name}"
153 trigger-on: "{obj:gerrit_merge_triggers}"
154 projects:
155 - project-compare-type: ANT
156 project-pattern: "{project}"
157 branches:
158 - branch-compare-type: ANT
159 branch-pattern: "**/{branch}"
160 file-paths: "{obj:gerrit_trigger_file_paths}"