Refactor templates and scripts for container tag
[releng/global-jjb.git] / docs / jjb / lf-docker-jobs.rst
1 ###########
2 Docker Jobs
3 ###########
4
5 Job Groups
6 ==========
7
8 .. include:: ../job-groups.rst
9
10 Below is a list of Docker job groups:
11
12 .. literalinclude:: ../../jjb/lf-docker-job-groups.yaml
13    :language: yaml
14
15
16 Macros
17 ======
18
19 lf-docker-get-container-tag
20 ---------------------------
21
22 Chooses a container tag to label the image based on the 'container-tag-method'
23 parameter.  If container-tag-method: latest, the tag 'latest' is used.
24 If container-tag-method: git-describe, the tag is obtained using
25 the git describe command, which requires that the repository has a git tag.
26 If container-tag-method: yaml-file, the tag is obtained using
27 the yq command, which requires that the repository has a YAML file named
28 'container-tag.yaml'. The script checks the docker-root directory by
29 default or the directory specified by parameter container-tag-yaml-dir.
30 An example file appears below.
31
32
33 lf-docker-build
34 ---------------
35
36 Calls docker build to build the container.
37
38 lf-docker-push
39 --------------
40
41 Calls docker-push.sh script to push docker images.
42
43 Job Templates
44 =============
45
46 Docker Verify
47 -------------
48
49 Executes a docker build task.
50
51 :Template Names:
52
53     - {project-name}-docker-verify-{stream}
54     - gerrit-docker-verify
55     - github-docker-verify
56
57 :Comment Trigger: recheck|reverify
58
59 :Required parameters:
60
61     :build-node: The node to run build on.
62     :container-public-registry: Docker registry source with base images.
63     :docker-name: Name of the Docker image.
64     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
65         be configured in defaults.yaml)
66     :mvn-settings: Maven settings.xml file containing credentials to use.
67
68 :Optional parameters:
69
70     :branch: Git branch to fetch for the build. (default: master)
71     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
72     :build-timeout: Timeout in minutes before aborting build. (default: 60)
73     :container-tag-method: Specifies the docker tag-choosing method.
74         Options are "latest", "git-describe" or "yaml-file".
75         Option git-describe requires a git tag to exist in the repository.
76         Option yaml-file requires a file "container-tag.yaml" to exist in the repository.
77         (default: latest)
78     :container-tag-yaml-dir: Directory with container-tag.yaml. (default: $DOCKER_ROOT)
79     :docker-build-args: Additional arguments for the docker build command.
80     :docker-root: Build directory within the repo. (default: $WORKSPACE, the repo root)
81     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
82     :pre_docker_build_script: Build script to execute before the main verify
83         builder steps. (default: a string with only a comment)
84     :post_docker_build_script: Build script to execute after the main verify
85         builder steps. (default: a string with only a comment)
86     :stream: Keyword that can be used to represent a release code-name.
87         Often the same as the branch. (default: master)
88     :submodule-recursive: Whether to checkout submodules recursively.
89         (default: true)
90     :submodule-timeout: Timeout (in minutes) for checkout operation.
91         (default: 10)
92
93     :gerrit_verify_triggers: Override Gerrit Triggers.
94     :gerrit_trigger_file_paths: Override Gerrit file paths which can be
95         used to filter which file modifications will trigger a build.
96     :github_included_regions: Override Github file paths which can be
97         used to filter which file modifications will trigger a build;
98         must match parameter gerrit_trigger_file_paths
99
100
101 container-tag.yaml example:
102
103 .. code-block:: yaml
104
105    ---
106    tag: 1.0.0
107
108 Docker Merge
109 ------------
110
111 Executes a docker build task and publishes the resulting images to a specified Docker registry.
112
113 :Template Names:
114
115     - {project-name}-docker-merge-{stream}
116     - gerrit-docker-merge
117     - github-docker-merge
118
119 :Comment Trigger: remerge
120
121 :Required parameters:
122
123     :build-node: The node to run build on.
124     :container-public-registry: Docker registry source with base images.
125     :container-push-registry: Docker registry target for the deploy action.
126     :docker-name: Name of the Docker image.
127     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
128         be configured in defaults.yaml)
129     :mvn-settings: Maven settings.xml file containing credentials to use.
130
131 :Optional parameters:
132
133     :branch: Git branch to fetch for the build. (default: master)
134     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
135     :build-timeout: Timeout in minutes before aborting build. (default: 60)
136     :container-tag-method: Specifies the docker tag-choosing method.
137         Options are "latest", "git-describe" or "yaml-file".
138         Option git-describe requires a git tag to exist in the repository.
139         Option yaml-file requires a file "container-tag.yaml" to exist in the repository.
140         (default: latest)
141     :container-tag-yaml-dir: Directory with container-tag.yaml. (default: $DOCKER_ROOT)
142     :cron: Cron schedule when to trigger the job. This parameter also
143         supports multiline input via YAML pipe | character in cases where
144         one may want to provide more than 1 cron timer. No default. Use
145         '@daily' to run daily or 'H H * * 0' to run weekly.
146     :docker-build-args: Additional arguments for the docker build command.
147     :docker-root: Build directory within the repo. (default: $WORKSPACE, the repo root)
148     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
149     :pre_docker_build_script: Build script to execute before the main merge
150         builder steps. (default: a string with only a comment)
151     :post_docker_build_script: Build script to execute after the main merge
152         builder steps. (default: a string with only a comment)
153     :stream: Keyword that can be used to represent a release code-name.
154         Often the same as the branch. (default: master)
155     :submodule-recursive: Whether to checkout submodules recursively.
156         (default: true)
157     :submodule-timeout: Timeout (in minutes) for checkout operation.
158         (default: 10)
159
160     :gerrit_merge_triggers: Override Gerrit Triggers.
161     :gerrit_trigger_file_paths: Override Gerrit file paths which can be
162         used to filter which file modifications will trigger a build.
163     :github_included_regions: Override Github file paths which can be
164         used to filter which file modifications will trigger a build;
165         must match parameter gerrit_trigger_file_paths
166
167 Sample container-tag.yaml File
168 ------------------------------
169
170 .. code-block:: yaml
171
172    ---
173    tag: 1.0.0