datadouble-jenkins 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- datadouble_jenkins-0.0.3/.gitignore +21 -0
- datadouble_jenkins-0.0.3/LICENSE +21 -0
- datadouble_jenkins-0.0.3/PKG-INFO +327 -0
- datadouble_jenkins-0.0.3/README.md +306 -0
- datadouble_jenkins-0.0.3/pyproject.toml +38 -0
- datadouble_jenkins-0.0.3/resources/datadouble/pod.sh +44 -0
- datadouble_jenkins-0.0.3/resources/datadouble/run.sh +72 -0
- datadouble_jenkins-0.0.3/src/datadouble_jenkins/__init__.py +667 -0
- datadouble_jenkins-0.0.3/src/datadouble_jenkins/py.typed +0 -0
- datadouble_jenkins-0.0.3/tests/golden/git/datadouble-shop-build.Jenkinsfile.golden +82 -0
- datadouble_jenkins-0.0.3/tests/golden/git/datadouble-shop-promote.Jenkinsfile.golden +79 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-export-claim/datadouble-shop-build.Jenkinsfile.golden +115 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-export-claim/datadouble-shop-lock.Jenkinsfile.golden +110 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-export-claim/datadouble-shop-promote.Jenkinsfile.golden +117 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-export-claim/datadouble-shop-prune-production.Jenkinsfile.golden +132 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-export-claim-non-production/datadouble-shop-activate.Jenkinsfile.golden +112 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-export-claim-non-production/datadouble-shop-fetch.Jenkinsfile.golden +112 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-export-claim-non-production/datadouble-shop-provision.Jenkinsfile.golden +112 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-export-claim-non-production/datadouble-shop-prune-non-production.Jenkinsfile.golden +115 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-export-claim-non-production/datadouble-shop-release.Jenkinsfile.golden +129 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-git/datadouble-shop-fetch.Jenkinsfile.golden +119 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-mounted/datadouble-shop-fetch.Jenkinsfile.golden +118 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-on-demand/datadouble-shop-activate.Jenkinsfile.golden +114 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-on-demand/datadouble-shop-fetch.Jenkinsfile.golden +114 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-on-demand/datadouble-shop-provision.Jenkinsfile.golden +114 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-on-demand/datadouble-shop-prune-non-production.Jenkinsfile.golden +117 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-on-demand/datadouble-shop-release.Jenkinsfile.golden +131 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-production/datadouble-shop-build.Jenkinsfile.golden +118 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-production/datadouble-shop-lock.Jenkinsfile.golden +113 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-production/datadouble-shop-promote.Jenkinsfile.golden +115 -0
- datadouble_jenkins-0.0.3/tests/golden/kubernetes-production/datadouble-shop-prune-production.Jenkinsfile.golden +130 -0
- datadouble_jenkins-0.0.3/tests/golden/manual/datadouble-shop-build.Jenkinsfile.golden +75 -0
- datadouble_jenkins-0.0.3/tests/golden/manual/datadouble-shop-lock.Jenkinsfile.golden +73 -0
- datadouble_jenkins-0.0.3/tests/golden/manual/datadouble-shop-promote.Jenkinsfile.golden +72 -0
- datadouble_jenkins-0.0.3/tests/golden/manual/datadouble-shop-prune-production.Jenkinsfile.golden +89 -0
- datadouble_jenkins-0.0.3/tests/golden/mirror/datadouble-shop-build.Jenkinsfile.golden +75 -0
- datadouble_jenkins-0.0.3/tests/golden/mirror/datadouble-shop-promote.Jenkinsfile.golden +72 -0
- datadouble_jenkins-0.0.3/tests/golden/mounted/datadouble-shop-fetch.Jenkinsfile.golden +72 -0
- datadouble_jenkins-0.0.3/tests/golden/on-demand/datadouble-shop-activate.Jenkinsfile.golden +72 -0
- datadouble_jenkins-0.0.3/tests/golden/on-demand/datadouble-shop-fetch.Jenkinsfile.golden +72 -0
- datadouble_jenkins-0.0.3/tests/golden/on-demand/datadouble-shop-provision.Jenkinsfile.golden +72 -0
- datadouble_jenkins-0.0.3/tests/golden/on-demand/datadouble-shop-prune-non-production.Jenkinsfile.golden +75 -0
- datadouble_jenkins-0.0.3/tests/golden/on-demand/datadouble-shop-release.Jenkinsfile.golden +91 -0
- datadouble_jenkins-0.0.3/tests/golden/pool/datadouble-shop-fetch.Jenkinsfile.golden +72 -0
- datadouble_jenkins-0.0.3/tests/golden/pool/datadouble-shop-provision.Jenkinsfile.golden +73 -0
- datadouble_jenkins-0.0.3/tests/golden/pool/datadouble-shop-release.Jenkinsfile.golden +72 -0
- datadouble_jenkins-0.0.3/tests/golden/production/datadouble-shop-build.Jenkinsfile.golden +75 -0
- datadouble_jenkins-0.0.3/tests/golden/production/datadouble-shop-lock.Jenkinsfile.golden +70 -0
- datadouble_jenkins-0.0.3/tests/golden/production/datadouble-shop-promote.Jenkinsfile.golden +72 -0
- datadouble_jenkins-0.0.3/tests/golden/production/datadouble-shop-prune-production.Jenkinsfile.golden +89 -0
- datadouble_jenkins-0.0.3/tests/test_jenkins.py +721 -0
- datadouble_jenkins-0.0.3/tests/test_jenkins_conformance.py +457 -0
- datadouble_jenkins-0.0.3/tests/test_jenkins_kubernetes_conformance.py +479 -0
- datadouble_jenkins-0.0.3/vars/datadouble.groovy +79 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright (c) 2026- Tight Line LLC
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[cod]
|
|
6
|
+
.venv/
|
|
7
|
+
.env
|
|
8
|
+
.coverage
|
|
9
|
+
.coverage.*
|
|
10
|
+
coverage.xml
|
|
11
|
+
.reports/
|
|
12
|
+
.pytest_cache/
|
|
13
|
+
.mypy_cache/
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
dist/
|
|
16
|
+
site/
|
|
17
|
+
.cache/
|
|
18
|
+
|
|
19
|
+
# The default work directory of `datadouble run`.
|
|
20
|
+
.datadouble/
|
|
21
|
+
node_modules/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026- Tight Line LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: datadouble-jenkins
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: Jenkins CI/CD adapter for Datadouble
|
|
5
|
+
Project-URL: Homepage, https://datadouble.tightlinesoftware.com/
|
|
6
|
+
Project-URL: Source, https://github.com/datadouble/datadouble
|
|
7
|
+
Author: Tight Line LLC
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
15
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Python: >=3.13
|
|
18
|
+
Requires-Dist: datadouble
|
|
19
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# datadouble-jenkins
|
|
23
|
+
|
|
24
|
+
The Jenkins CI/CD adapter for
|
|
25
|
+
[Datadouble](https://datadouble.tightlinesoftware.com/). It has two parts:
|
|
26
|
+
|
|
27
|
+
- **The shared library in this directory** (`vars/datadouble.groovy` and
|
|
28
|
+
the scripts in `resources/datadouble/`), whose `datadouble` step runs one
|
|
29
|
+
`datadouble` command in the Datadouble image: with `docker run` on an agent
|
|
30
|
+
with Docker (`run.sh`), or in the Datadouble container of a Kubernetes
|
|
31
|
+
agent's pod (`pod.sh`).
|
|
32
|
+
- **The Python package,** which writes Jenkinsfiles for `datadouble ci init
|
|
33
|
+
--system jenkins` and, at run time, reports a response's outputs and
|
|
34
|
+
outcome to the step.
|
|
35
|
+
|
|
36
|
+
## Writing Jenkinsfiles
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
datadouble ci init --system jenkins --job build,promote,prune,lock \
|
|
40
|
+
--spec datadouble/shop.yml --runner prod-db --work /srv/datadouble/work
|
|
41
|
+
datadouble ci init --system jenkins --job fetch,provision,release,prune,activate \
|
|
42
|
+
--spec datadouble/shop.yml --runner staging
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Each job gets a declarative Jenkinsfile, `jenkins/datadouble-<spec>-<job>.Jenkinsfile`,
|
|
46
|
+
for a Pipeline job of the same name. It loads the shared library from this
|
|
47
|
+
repository at the release's tag (`library` with `modernSCM` and
|
|
48
|
+
`libraryPath: 'ci/jenkins/'`), so Jenkins needs no global library set up,
|
|
49
|
+
only the Pipeline: Groovy Libraries and Git plugins.
|
|
50
|
+
|
|
51
|
+
The Jenkins controller clones the library before any agent starts, so it
|
|
52
|
+
must reach the repository. A controller that can only reach a Git server
|
|
53
|
+
inside its network can load the library from a mirror there instead:
|
|
54
|
+
`ci init --library-remote https://git.example.com/mirrors/datadouble.git`
|
|
55
|
+
writes that URL into every Jenkinsfile. The mirror must hold the release's
|
|
56
|
+
tag (`v<version>`), with `ci/jenkins/` in it, and the Git plugin must be able
|
|
57
|
+
to clone it, with a credential if it needs one. The URL can't hold spaces,
|
|
58
|
+
quotes or backslashes. The response lists:
|
|
59
|
+
|
|
60
|
+
- **The Pipeline jobs to create,** each running its Jenkinsfile from your
|
|
61
|
+
repository. Build each once: Jenkins reads a Jenkinsfile's triggers and
|
|
62
|
+
parameters when it runs.
|
|
63
|
+
- **The credentials** to add as Secret text, with IDs matching the
|
|
64
|
+
environment variables the jobs read. `withCredentials` binds them, and
|
|
65
|
+
Jenkins masks them in logs. The web form takes one line, so create a
|
|
66
|
+
multi-line one, such as a kubeconfig, through the API or Configuration as
|
|
67
|
+
Code.
|
|
68
|
+
|
|
69
|
+
Schedules are `cron` triggers in UTC. `promote` has an `upstream` trigger on
|
|
70
|
+
`build` that accepts an unstable build, and a pool's `provision` one on
|
|
71
|
+
`fetch`. Jobs never run two builds at once (`disableConcurrentBuilds`).
|
|
72
|
+
|
|
73
|
+
With `--manual`, for trying a branch's jobs, the Jenkinsfiles have no
|
|
74
|
+
`triggers` block. Build each job once all the same, so Jenkins reads its
|
|
75
|
+
parameters. A manual `prune` is a dry run unless `DRY_RUN` is unticked, so
|
|
76
|
+
that first build removes nothing. After it, only a person starts the job, or
|
|
77
|
+
a request for on-demand copies. The job names are the real jobs' names, so
|
|
78
|
+
keep a branch's jobs in a folder of their own.
|
|
79
|
+
|
|
80
|
+
## On-demand copies and retries
|
|
81
|
+
|
|
82
|
+
Jenkins has no pull request events that every installation shares, so
|
|
83
|
+
`provision` and `release` take an `OWNER` parameter. Start them from a
|
|
84
|
+
request's own pipeline:
|
|
85
|
+
|
|
86
|
+
```groovy
|
|
87
|
+
build(job: 'datadouble-shop-provision', parameters: [string(name: 'OWNER', value: "pr-${env.CHANGE_ID}")])
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`release` without an `OWNER` is the scheduled sweep of expired copies.
|
|
91
|
+
|
|
92
|
+
A retried Jenkins build is a new build, with a new `BUILD_TAG`. To resume a
|
|
93
|
+
`build` that failed part way, start it with `RETRY_KEY` set to the failed
|
|
94
|
+
build's `BUILD_TAG`, shown at the top of its log.
|
|
95
|
+
|
|
96
|
+
## Where jobs find the spec
|
|
97
|
+
|
|
98
|
+
By default each Jenkinsfile reads the spec, the specs it extends and its
|
|
99
|
+
lock from the build's checkout of this repository. `--spec-source` changes
|
|
100
|
+
that (see [where jobs find the spec](https://datadouble.tightlinesoftware.com/ci-cd/#where-jobs-find-the-spec)):
|
|
101
|
+
|
|
102
|
+
- `--spec-source mounted --spec-dir DIR`: on an agent with Docker, the
|
|
103
|
+
spec's directory is `DIR` on the agent, mounted into each job at the same
|
|
104
|
+
path. On Kubernetes agents, also name a ConfigMap you manage with
|
|
105
|
+
`--spec-config-map NAME`, keyed by file name. The pod mounts it
|
|
106
|
+
read-only at `DIR` in the Datadouble container.
|
|
107
|
+
- `--spec-source git --spec-repository URL --spec-ref REF --spec-dir DIR
|
|
108
|
+
--spec-credential ID`: each Jenkinsfile starts with a `spec` stage that
|
|
109
|
+
runs `checkout scmGit(...)` inside `dir('.datadouble-spec')`, with the
|
|
110
|
+
credential `ID`: Username with password (an access token as the
|
|
111
|
+
password), or SSH Username with private key for an SSH URL. The
|
|
112
|
+
response's instructions name it. `REF` is a branch by its name, a tag as `refs/tags/<tag>`, or a commit
|
|
113
|
+
by its full SHA. The Git plugin
|
|
114
|
+
doesn't recognize a bare tag name.
|
|
115
|
+
|
|
116
|
+
## Re-locking the catalog
|
|
117
|
+
|
|
118
|
+
The manual `lock` job (`--job lock`, on the production side with `build`)
|
|
119
|
+
re-locks after a schema change. It runs `datadouble lock --output
|
|
120
|
+
datadouble-lock` and archives the new lock (named after the spec, such as
|
|
121
|
+
`shop.lock`) and `changes.txt` as the build's artifacts. It never commits:
|
|
122
|
+
download them from the build's page, check every new or changed column in
|
|
123
|
+
`changes.txt` for personal data, then commit the lock beside the spec. A lock
|
|
124
|
+
contains names, types and versions, never values (decision 123).
|
|
125
|
+
|
|
126
|
+
## What a job needs on its agent
|
|
127
|
+
|
|
128
|
+
- The labels given to `--runner`.
|
|
129
|
+
- Docker, with its socket at `/var/run/docker.sock` unless the agent says
|
|
130
|
+
otherwise (below), usable by the agent's user. The step runs the
|
|
131
|
+
Datadouble image as the engine's user on the host's network, with the
|
|
132
|
+
workspace and every absolute path in the spec mounted at the same path.
|
|
133
|
+
- Those paths, existing and owned by the engine's user (`999:999` for
|
|
134
|
+
PostgreSQL).
|
|
135
|
+
- On agents inside the production boundary, `DATADOUBLE_BOUNDARY=inside` in
|
|
136
|
+
the agent's environment (decision 98).
|
|
137
|
+
|
|
138
|
+
### Another Docker command or socket
|
|
139
|
+
|
|
140
|
+
The step runs the image with `docker` and the daemon at
|
|
141
|
+
`/var/run/docker.sock`. Where Docker is installed outside `PATH`, or the
|
|
142
|
+
daemon is another Docker-compatible one listening on another socket, set
|
|
143
|
+
`DATADOUBLE_DOCKER` (one program, a name or an absolute path) and
|
|
144
|
+
`DATADOUBLE_DOCKER_SOCKET` (an absolute path) in the agent's environment,
|
|
145
|
+
once for every job on the agent. Or pass `--docker` and `--docker-socket` to
|
|
146
|
+
`ci init`, which writes them into the Jenkinsfiles as the step's `docker`
|
|
147
|
+
and `dockerSocket`, where they take precedence over the agent's own
|
|
148
|
+
(decision 126).
|
|
149
|
+
|
|
150
|
+
Without `DATADOUBLE_DOCKER_SOCKET`, a `DOCKER_HOST` of the form
|
|
151
|
+
`unix://PATH` in the agent's environment names the socket. A socket named
|
|
152
|
+
either way is also the daemon the image is started on (`DOCKER_HOST`, and
|
|
153
|
+
`CONTAINER_HOST` for podman), so the image and the engines' containers share
|
|
154
|
+
one daemon. The socket is mounted at `/var/run/docker.sock` inside the
|
|
155
|
+
Datadouble container, and `DOCKER_HOST` there always points at it, even when
|
|
156
|
+
a job passes its own `DOCKER_HOST` on.
|
|
157
|
+
|
|
158
|
+
Rootless Docker is not supported: its user namespace maps the engine's user
|
|
159
|
+
to another one on the host, so neither the socket's group nor the files
|
|
160
|
+
shared at the same paths (decision 73) line up. The step reads the socket's
|
|
161
|
+
group with GNU `stat`, so the agent needs GNU coreutils, as Linux
|
|
162
|
+
distributions have.
|
|
163
|
+
|
|
164
|
+
## Kubernetes agents
|
|
165
|
+
|
|
166
|
+
Jenkins installations whose agents are pods of the Kubernetes plugin often
|
|
167
|
+
have no Docker, and the spec's `kubernetes` runtime needs Datadouble itself
|
|
168
|
+
in a pod that shares the engine pods' work claim. With `--agent kubernetes`
|
|
169
|
+
each Jenkinsfile declares its own pod instead of a label. As for Argo CD
|
|
170
|
+
(decision 103), `--runner` sets the side's namespace; `--cloud` sets the
|
|
171
|
+
plugin's cloud, and without it the pods start in the plugin's default cloud.
|
|
172
|
+
Agents with Docker stay the default (`--agent docker`).
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
datadouble ci init --system jenkins --agent kubernetes --job build,promote,prune \
|
|
176
|
+
--spec datadouble/shop.yml --runner shop-production --cloud prod-k8s \
|
|
177
|
+
--work /srv/datadouble/work
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
```groovy
|
|
181
|
+
agent {
|
|
182
|
+
kubernetes {
|
|
183
|
+
cloud 'prod-k8s'
|
|
184
|
+
namespace 'shop-production'
|
|
185
|
+
yaml '''
|
|
186
|
+
apiVersion: v1
|
|
187
|
+
kind: Pod
|
|
188
|
+
spec:
|
|
189
|
+
serviceAccountName: datadouble-shop-production
|
|
190
|
+
containers:
|
|
191
|
+
- name: jnlp
|
|
192
|
+
...
|
|
193
|
+
- name: datadouble
|
|
194
|
+
image: ghcr.io/datadouble/datadouble:v...
|
|
195
|
+
securityContext: {runAsUser: 999, runAsGroup: 999, ...}
|
|
196
|
+
...
|
|
197
|
+
'''
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
- **Each side has its own namespace,** and the two sides must not share one;
|
|
203
|
+
separate clusters are better still. A namespace's `datadouble` claim holds
|
|
204
|
+
its side's files, and production's holds data extracted from the source.
|
|
205
|
+
Generate each side with its own `--runner`.
|
|
206
|
+
- **The pod mounts its namespace's `datadouble` claim** where the side's paths
|
|
207
|
+
are. Jobs that start engine software (`build`, `provision`, `release`) need
|
|
208
|
+
the spec's `kubernetes` runtime on the claim `datadouble`, with every path
|
|
209
|
+
in the spec (stores, staging, the work directory) under its `mount`,
|
|
210
|
+
which is where the pod mounts the claim, the same path the engine pods
|
|
211
|
+
use. Other jobs mount the claim at their paths' common directory, as Argo
|
|
212
|
+
CD does. `ci init` refuses anything else. The pod keeps to the runtime's
|
|
213
|
+
`node` when one is set, and uses its `image_pull_secrets`.
|
|
214
|
+
- **Other claims the runtime lists in `claims`** are the exception. A job's
|
|
215
|
+
pod mounts each one its paths are on, at its own `mount`, and engine pods
|
|
216
|
+
never do, so only jobs that start no engines may name paths on them. A job
|
|
217
|
+
mounts only the claims its paths are on, so one spec can name a claim only
|
|
218
|
+
one side has. That keeps `promote`'s export on
|
|
219
|
+
a share a web server can serve, apart from the work directory. The
|
|
220
|
+
Kubernetes adapter's README explains the setting.
|
|
221
|
+
- **Leave the runtime's `namespace` out.** The engine pods then start in the
|
|
222
|
+
namespace of the job's own pod, read from its service account, so one
|
|
223
|
+
spec serves both sides, each in its own namespace. A runtime that names a
|
|
224
|
+
namespace must name this side's `--runner`, so `ci init` refuses a spec
|
|
225
|
+
naming production's namespace for the non-production jobs.
|
|
226
|
+
- **Only the Datadouble container runs as the engine's user** (decision 86).
|
|
227
|
+
The plugin's agent container (`jnlp`) keeps its image's user, whose account
|
|
228
|
+
and home an SCM checkout over SSH needs. The two share the workspace, so
|
|
229
|
+
the agent container starts with umask `0000`, which leaves the directories
|
|
230
|
+
it creates, including each `sh` step's control directory, writable by the
|
|
231
|
+
Datadouble container. That workspace is the pod's own and goes with it.
|
|
232
|
+
The override runs `/usr/local/bin/jenkins-agent`, as in the
|
|
233
|
+
`jenkins/inbound-agent` image the plugin uses by default; a cloud with
|
|
234
|
+
another agent image needs that path.
|
|
235
|
+
- **The step runs `datadouble` in the Datadouble container** with
|
|
236
|
+
`container`, with secrets bound by `withCredentials` as in Docker mode.
|
|
237
|
+
- **The boundary mark is only the namespace's** `datadouble-boundary`
|
|
238
|
+
ConfigMap, which the operator creates in production namespaces, as for the
|
|
239
|
+
Helm chart. The pod mounts it as an optional volume and the step reads the
|
|
240
|
+
file. It ignores every environment variable for the mark, since Jenkins
|
|
241
|
+
lays its own environment (global variables, `withEnv`) over the
|
|
242
|
+
container's, so a pod in an unmarked namespace is refused `build` and
|
|
243
|
+
`promote` whatever Jenkins sets.
|
|
244
|
+
- **Engine pods see only the claim.** Anything an engine pod reads must be on
|
|
245
|
+
it, not in the workspace.
|
|
246
|
+
- **There is no Docker,** so `--docker` and `--docker-socket` are refused.
|
|
247
|
+
The rest is as on Docker agents: each step names its job for `notify`'s
|
|
248
|
+
webhooks, `post` sends its email, and the `lock` job's new lock and changes
|
|
249
|
+
are archived as the build's artifacts.
|
|
250
|
+
|
|
251
|
+
The response's `instructions` list what to set up:
|
|
252
|
+
|
|
253
|
+
- Separate namespaces for the two sides.
|
|
254
|
+
- The Kubernetes plugin and its cloud, whose credentials need a Role in the
|
|
255
|
+
namespace with the rights the plugin's own documentation lists: `create`,
|
|
256
|
+
`delete`, `get`, `list`, `patch`, `update` and `watch` on pods, `create`
|
|
257
|
+
and `get` on `pods/exec` (the `container` step), `get`, `list` and `watch`
|
|
258
|
+
on `pods/log`, and `watch` on events. `CLOUD_RULES` in the package holds
|
|
259
|
+
them, and `ACCOUNT_RULES` the service account's below.
|
|
260
|
+
- The `datadouble` claim: `ReadWriteMany`, or `ReadWriteOnce` with the
|
|
261
|
+
runtime's `node` set so every pod runs on that node, owned by the engine's
|
|
262
|
+
user.
|
|
263
|
+
- Each other claim the runtime's `claims` lists, owned by the engine's user.
|
|
264
|
+
- The service account `datadouble-<spec>-<side>` the pods run as, with a Role
|
|
265
|
+
allowing `get`, `list`, `watch`, `create`, `delete` and `patch` on pods,
|
|
266
|
+
`pods/log`, `pods/exec`, `pods/portforward` and Secrets, and `get` and
|
|
267
|
+
`list` on PersistentVolumeClaims; on the non-production side, a
|
|
268
|
+
ClusterRole for PersistentVolumes as well, which the `k8s-pv` replicate
|
|
269
|
+
adapter makes.
|
|
270
|
+
- On the production side, the `datadouble-boundary` ConfigMap, inside the
|
|
271
|
+
production boundary only.
|
|
272
|
+
|
|
273
|
+
The conformance suite runs Kubernetes agents end to end in their own CI job
|
|
274
|
+
(`make test-ci SYSTEM=jenkins-kubernetes`): Jenkins with the plugin, whose
|
|
275
|
+
cloud has exactly `CLOUD_RULES`, runs every job of both sides as a pod on a
|
|
276
|
+
kind cluster, each side in its own namespace from one spec whose runtime
|
|
277
|
+
names none, and each build's pod must hold everything its Jenkinsfile
|
|
278
|
+
declares; each side's engine pods must start in that side's namespace. A
|
|
279
|
+
namespace without the ConfigMap is refused `build`, `promote` and `lock`
|
|
280
|
+
while Jenkins' global environment sets `DATADOUBLE_BOUNDARY=inside`.
|
|
281
|
+
|
|
282
|
+
- **The plugin's agent image** must be one the pods can pull; the suite
|
|
283
|
+
loads `jenkins/inbound-agent` into the cluster and names it to the plugin
|
|
284
|
+
(`PodTemplateStepExecution.defaultImage`).
|
|
285
|
+
- **A finished pod's workspace goes with it,** and the step's outputs are
|
|
286
|
+
in the workspace. The step returns them to the Jenkinsfile; to read them
|
|
287
|
+
from outside, as the suite does, keep finished pods (the cloud's pod
|
|
288
|
+
retention) and read `.datadouble-outputs` from the Datadouble container.
|
|
289
|
+
|
|
290
|
+
## Outcomes
|
|
291
|
+
|
|
292
|
+
| Outcome | The build | The step returns |
|
|
293
|
+
|---|---|---|
|
|
294
|
+
| success | succeeds | `outcome`, `generation` for `run` |
|
|
295
|
+
| warning | unstable | as above |
|
|
296
|
+
| failure | fails | `error`, the error code |
|
|
297
|
+
|
|
298
|
+
The step sets the build's description to the generation it built. Only the
|
|
299
|
+
`lock` job archives build artifacts: its lock and changes, which hold no data
|
|
300
|
+
values.
|
|
301
|
+
|
|
302
|
+
## Notifications
|
|
303
|
+
|
|
304
|
+
The spec's `notify` section configures notifications for jobs that fail,
|
|
305
|
+
warn or recover. Each `datadouble` step names its job (`job: 'build'`), so Datadouble posts the
|
|
306
|
+
spec's webhooks itself after the command, with the build's page
|
|
307
|
+
(`BUILD_URL`, set when Jenkins knows its own URL) as `run_url`. Add the
|
|
308
|
+
webhook's variable as a Secret text credential like the others.
|
|
309
|
+
|
|
310
|
+
`notify`'s email is Jenkins' own `mail` step (the Mailer plugin, with the
|
|
311
|
+
SMTP server set in Manage Jenkins), in the Jenkinsfile's `post` section:
|
|
312
|
+
`failure` and `aborted` (a build stopped at its time limit) for failures,
|
|
313
|
+
`unstable` for warnings, and `fixed` for recoveries. Its subject names the
|
|
314
|
+
build's result (failure, aborted or unstable, or "recovered" for `fixed`),
|
|
315
|
+
and its body adds the build's URL when Jenkins knows it. Jenkins judges
|
|
316
|
+
`fixed` from the previous build: a success after a failed or unstable one,
|
|
317
|
+
not after an aborted one. Because
|
|
318
|
+
`post` runs however the build ended, it also reports a build that failed
|
|
319
|
+
before Datadouble started, such as an image that cannot be pulled, which
|
|
320
|
+
posts no webhook. A notification that cannot be sent, by mail or webhook, is
|
|
321
|
+
logged and leaves the build's result alone.
|
|
322
|
+
|
|
323
|
+
For a recovery webhook, each command line records its last outcome in a
|
|
324
|
+
file `ci init` names (`--ci-record`), under `.datadouble-notify/` in the work
|
|
325
|
+
directory on the production side and in staging on the other. Every
|
|
326
|
+
production Jenkinsfile then mounts the work directory, so it must exist on
|
|
327
|
+
the agent, owned by the engine's user, as for `build`.
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
# datadouble-jenkins
|
|
2
|
+
|
|
3
|
+
The Jenkins CI/CD adapter for
|
|
4
|
+
[Datadouble](https://datadouble.tightlinesoftware.com/). It has two parts:
|
|
5
|
+
|
|
6
|
+
- **The shared library in this directory** (`vars/datadouble.groovy` and
|
|
7
|
+
the scripts in `resources/datadouble/`), whose `datadouble` step runs one
|
|
8
|
+
`datadouble` command in the Datadouble image: with `docker run` on an agent
|
|
9
|
+
with Docker (`run.sh`), or in the Datadouble container of a Kubernetes
|
|
10
|
+
agent's pod (`pod.sh`).
|
|
11
|
+
- **The Python package,** which writes Jenkinsfiles for `datadouble ci init
|
|
12
|
+
--system jenkins` and, at run time, reports a response's outputs and
|
|
13
|
+
outcome to the step.
|
|
14
|
+
|
|
15
|
+
## Writing Jenkinsfiles
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
datadouble ci init --system jenkins --job build,promote,prune,lock \
|
|
19
|
+
--spec datadouble/shop.yml --runner prod-db --work /srv/datadouble/work
|
|
20
|
+
datadouble ci init --system jenkins --job fetch,provision,release,prune,activate \
|
|
21
|
+
--spec datadouble/shop.yml --runner staging
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Each job gets a declarative Jenkinsfile, `jenkins/datadouble-<spec>-<job>.Jenkinsfile`,
|
|
25
|
+
for a Pipeline job of the same name. It loads the shared library from this
|
|
26
|
+
repository at the release's tag (`library` with `modernSCM` and
|
|
27
|
+
`libraryPath: 'ci/jenkins/'`), so Jenkins needs no global library set up,
|
|
28
|
+
only the Pipeline: Groovy Libraries and Git plugins.
|
|
29
|
+
|
|
30
|
+
The Jenkins controller clones the library before any agent starts, so it
|
|
31
|
+
must reach the repository. A controller that can only reach a Git server
|
|
32
|
+
inside its network can load the library from a mirror there instead:
|
|
33
|
+
`ci init --library-remote https://git.example.com/mirrors/datadouble.git`
|
|
34
|
+
writes that URL into every Jenkinsfile. The mirror must hold the release's
|
|
35
|
+
tag (`v<version>`), with `ci/jenkins/` in it, and the Git plugin must be able
|
|
36
|
+
to clone it, with a credential if it needs one. The URL can't hold spaces,
|
|
37
|
+
quotes or backslashes. The response lists:
|
|
38
|
+
|
|
39
|
+
- **The Pipeline jobs to create,** each running its Jenkinsfile from your
|
|
40
|
+
repository. Build each once: Jenkins reads a Jenkinsfile's triggers and
|
|
41
|
+
parameters when it runs.
|
|
42
|
+
- **The credentials** to add as Secret text, with IDs matching the
|
|
43
|
+
environment variables the jobs read. `withCredentials` binds them, and
|
|
44
|
+
Jenkins masks them in logs. The web form takes one line, so create a
|
|
45
|
+
multi-line one, such as a kubeconfig, through the API or Configuration as
|
|
46
|
+
Code.
|
|
47
|
+
|
|
48
|
+
Schedules are `cron` triggers in UTC. `promote` has an `upstream` trigger on
|
|
49
|
+
`build` that accepts an unstable build, and a pool's `provision` one on
|
|
50
|
+
`fetch`. Jobs never run two builds at once (`disableConcurrentBuilds`).
|
|
51
|
+
|
|
52
|
+
With `--manual`, for trying a branch's jobs, the Jenkinsfiles have no
|
|
53
|
+
`triggers` block. Build each job once all the same, so Jenkins reads its
|
|
54
|
+
parameters. A manual `prune` is a dry run unless `DRY_RUN` is unticked, so
|
|
55
|
+
that first build removes nothing. After it, only a person starts the job, or
|
|
56
|
+
a request for on-demand copies. The job names are the real jobs' names, so
|
|
57
|
+
keep a branch's jobs in a folder of their own.
|
|
58
|
+
|
|
59
|
+
## On-demand copies and retries
|
|
60
|
+
|
|
61
|
+
Jenkins has no pull request events that every installation shares, so
|
|
62
|
+
`provision` and `release` take an `OWNER` parameter. Start them from a
|
|
63
|
+
request's own pipeline:
|
|
64
|
+
|
|
65
|
+
```groovy
|
|
66
|
+
build(job: 'datadouble-shop-provision', parameters: [string(name: 'OWNER', value: "pr-${env.CHANGE_ID}")])
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`release` without an `OWNER` is the scheduled sweep of expired copies.
|
|
70
|
+
|
|
71
|
+
A retried Jenkins build is a new build, with a new `BUILD_TAG`. To resume a
|
|
72
|
+
`build` that failed part way, start it with `RETRY_KEY` set to the failed
|
|
73
|
+
build's `BUILD_TAG`, shown at the top of its log.
|
|
74
|
+
|
|
75
|
+
## Where jobs find the spec
|
|
76
|
+
|
|
77
|
+
By default each Jenkinsfile reads the spec, the specs it extends and its
|
|
78
|
+
lock from the build's checkout of this repository. `--spec-source` changes
|
|
79
|
+
that (see [where jobs find the spec](https://datadouble.tightlinesoftware.com/ci-cd/#where-jobs-find-the-spec)):
|
|
80
|
+
|
|
81
|
+
- `--spec-source mounted --spec-dir DIR`: on an agent with Docker, the
|
|
82
|
+
spec's directory is `DIR` on the agent, mounted into each job at the same
|
|
83
|
+
path. On Kubernetes agents, also name a ConfigMap you manage with
|
|
84
|
+
`--spec-config-map NAME`, keyed by file name. The pod mounts it
|
|
85
|
+
read-only at `DIR` in the Datadouble container.
|
|
86
|
+
- `--spec-source git --spec-repository URL --spec-ref REF --spec-dir DIR
|
|
87
|
+
--spec-credential ID`: each Jenkinsfile starts with a `spec` stage that
|
|
88
|
+
runs `checkout scmGit(...)` inside `dir('.datadouble-spec')`, with the
|
|
89
|
+
credential `ID`: Username with password (an access token as the
|
|
90
|
+
password), or SSH Username with private key for an SSH URL. The
|
|
91
|
+
response's instructions name it. `REF` is a branch by its name, a tag as `refs/tags/<tag>`, or a commit
|
|
92
|
+
by its full SHA. The Git plugin
|
|
93
|
+
doesn't recognize a bare tag name.
|
|
94
|
+
|
|
95
|
+
## Re-locking the catalog
|
|
96
|
+
|
|
97
|
+
The manual `lock` job (`--job lock`, on the production side with `build`)
|
|
98
|
+
re-locks after a schema change. It runs `datadouble lock --output
|
|
99
|
+
datadouble-lock` and archives the new lock (named after the spec, such as
|
|
100
|
+
`shop.lock`) and `changes.txt` as the build's artifacts. It never commits:
|
|
101
|
+
download them from the build's page, check every new or changed column in
|
|
102
|
+
`changes.txt` for personal data, then commit the lock beside the spec. A lock
|
|
103
|
+
contains names, types and versions, never values (decision 123).
|
|
104
|
+
|
|
105
|
+
## What a job needs on its agent
|
|
106
|
+
|
|
107
|
+
- The labels given to `--runner`.
|
|
108
|
+
- Docker, with its socket at `/var/run/docker.sock` unless the agent says
|
|
109
|
+
otherwise (below), usable by the agent's user. The step runs the
|
|
110
|
+
Datadouble image as the engine's user on the host's network, with the
|
|
111
|
+
workspace and every absolute path in the spec mounted at the same path.
|
|
112
|
+
- Those paths, existing and owned by the engine's user (`999:999` for
|
|
113
|
+
PostgreSQL).
|
|
114
|
+
- On agents inside the production boundary, `DATADOUBLE_BOUNDARY=inside` in
|
|
115
|
+
the agent's environment (decision 98).
|
|
116
|
+
|
|
117
|
+
### Another Docker command or socket
|
|
118
|
+
|
|
119
|
+
The step runs the image with `docker` and the daemon at
|
|
120
|
+
`/var/run/docker.sock`. Where Docker is installed outside `PATH`, or the
|
|
121
|
+
daemon is another Docker-compatible one listening on another socket, set
|
|
122
|
+
`DATADOUBLE_DOCKER` (one program, a name or an absolute path) and
|
|
123
|
+
`DATADOUBLE_DOCKER_SOCKET` (an absolute path) in the agent's environment,
|
|
124
|
+
once for every job on the agent. Or pass `--docker` and `--docker-socket` to
|
|
125
|
+
`ci init`, which writes them into the Jenkinsfiles as the step's `docker`
|
|
126
|
+
and `dockerSocket`, where they take precedence over the agent's own
|
|
127
|
+
(decision 126).
|
|
128
|
+
|
|
129
|
+
Without `DATADOUBLE_DOCKER_SOCKET`, a `DOCKER_HOST` of the form
|
|
130
|
+
`unix://PATH` in the agent's environment names the socket. A socket named
|
|
131
|
+
either way is also the daemon the image is started on (`DOCKER_HOST`, and
|
|
132
|
+
`CONTAINER_HOST` for podman), so the image and the engines' containers share
|
|
133
|
+
one daemon. The socket is mounted at `/var/run/docker.sock` inside the
|
|
134
|
+
Datadouble container, and `DOCKER_HOST` there always points at it, even when
|
|
135
|
+
a job passes its own `DOCKER_HOST` on.
|
|
136
|
+
|
|
137
|
+
Rootless Docker is not supported: its user namespace maps the engine's user
|
|
138
|
+
to another one on the host, so neither the socket's group nor the files
|
|
139
|
+
shared at the same paths (decision 73) line up. The step reads the socket's
|
|
140
|
+
group with GNU `stat`, so the agent needs GNU coreutils, as Linux
|
|
141
|
+
distributions have.
|
|
142
|
+
|
|
143
|
+
## Kubernetes agents
|
|
144
|
+
|
|
145
|
+
Jenkins installations whose agents are pods of the Kubernetes plugin often
|
|
146
|
+
have no Docker, and the spec's `kubernetes` runtime needs Datadouble itself
|
|
147
|
+
in a pod that shares the engine pods' work claim. With `--agent kubernetes`
|
|
148
|
+
each Jenkinsfile declares its own pod instead of a label. As for Argo CD
|
|
149
|
+
(decision 103), `--runner` sets the side's namespace; `--cloud` sets the
|
|
150
|
+
plugin's cloud, and without it the pods start in the plugin's default cloud.
|
|
151
|
+
Agents with Docker stay the default (`--agent docker`).
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
datadouble ci init --system jenkins --agent kubernetes --job build,promote,prune \
|
|
155
|
+
--spec datadouble/shop.yml --runner shop-production --cloud prod-k8s \
|
|
156
|
+
--work /srv/datadouble/work
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
```groovy
|
|
160
|
+
agent {
|
|
161
|
+
kubernetes {
|
|
162
|
+
cloud 'prod-k8s'
|
|
163
|
+
namespace 'shop-production'
|
|
164
|
+
yaml '''
|
|
165
|
+
apiVersion: v1
|
|
166
|
+
kind: Pod
|
|
167
|
+
spec:
|
|
168
|
+
serviceAccountName: datadouble-shop-production
|
|
169
|
+
containers:
|
|
170
|
+
- name: jnlp
|
|
171
|
+
...
|
|
172
|
+
- name: datadouble
|
|
173
|
+
image: ghcr.io/datadouble/datadouble:v...
|
|
174
|
+
securityContext: {runAsUser: 999, runAsGroup: 999, ...}
|
|
175
|
+
...
|
|
176
|
+
'''
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
- **Each side has its own namespace,** and the two sides must not share one;
|
|
182
|
+
separate clusters are better still. A namespace's `datadouble` claim holds
|
|
183
|
+
its side's files, and production's holds data extracted from the source.
|
|
184
|
+
Generate each side with its own `--runner`.
|
|
185
|
+
- **The pod mounts its namespace's `datadouble` claim** where the side's paths
|
|
186
|
+
are. Jobs that start engine software (`build`, `provision`, `release`) need
|
|
187
|
+
the spec's `kubernetes` runtime on the claim `datadouble`, with every path
|
|
188
|
+
in the spec (stores, staging, the work directory) under its `mount`,
|
|
189
|
+
which is where the pod mounts the claim, the same path the engine pods
|
|
190
|
+
use. Other jobs mount the claim at their paths' common directory, as Argo
|
|
191
|
+
CD does. `ci init` refuses anything else. The pod keeps to the runtime's
|
|
192
|
+
`node` when one is set, and uses its `image_pull_secrets`.
|
|
193
|
+
- **Other claims the runtime lists in `claims`** are the exception. A job's
|
|
194
|
+
pod mounts each one its paths are on, at its own `mount`, and engine pods
|
|
195
|
+
never do, so only jobs that start no engines may name paths on them. A job
|
|
196
|
+
mounts only the claims its paths are on, so one spec can name a claim only
|
|
197
|
+
one side has. That keeps `promote`'s export on
|
|
198
|
+
a share a web server can serve, apart from the work directory. The
|
|
199
|
+
Kubernetes adapter's README explains the setting.
|
|
200
|
+
- **Leave the runtime's `namespace` out.** The engine pods then start in the
|
|
201
|
+
namespace of the job's own pod, read from its service account, so one
|
|
202
|
+
spec serves both sides, each in its own namespace. A runtime that names a
|
|
203
|
+
namespace must name this side's `--runner`, so `ci init` refuses a spec
|
|
204
|
+
naming production's namespace for the non-production jobs.
|
|
205
|
+
- **Only the Datadouble container runs as the engine's user** (decision 86).
|
|
206
|
+
The plugin's agent container (`jnlp`) keeps its image's user, whose account
|
|
207
|
+
and home an SCM checkout over SSH needs. The two share the workspace, so
|
|
208
|
+
the agent container starts with umask `0000`, which leaves the directories
|
|
209
|
+
it creates, including each `sh` step's control directory, writable by the
|
|
210
|
+
Datadouble container. That workspace is the pod's own and goes with it.
|
|
211
|
+
The override runs `/usr/local/bin/jenkins-agent`, as in the
|
|
212
|
+
`jenkins/inbound-agent` image the plugin uses by default; a cloud with
|
|
213
|
+
another agent image needs that path.
|
|
214
|
+
- **The step runs `datadouble` in the Datadouble container** with
|
|
215
|
+
`container`, with secrets bound by `withCredentials` as in Docker mode.
|
|
216
|
+
- **The boundary mark is only the namespace's** `datadouble-boundary`
|
|
217
|
+
ConfigMap, which the operator creates in production namespaces, as for the
|
|
218
|
+
Helm chart. The pod mounts it as an optional volume and the step reads the
|
|
219
|
+
file. It ignores every environment variable for the mark, since Jenkins
|
|
220
|
+
lays its own environment (global variables, `withEnv`) over the
|
|
221
|
+
container's, so a pod in an unmarked namespace is refused `build` and
|
|
222
|
+
`promote` whatever Jenkins sets.
|
|
223
|
+
- **Engine pods see only the claim.** Anything an engine pod reads must be on
|
|
224
|
+
it, not in the workspace.
|
|
225
|
+
- **There is no Docker,** so `--docker` and `--docker-socket` are refused.
|
|
226
|
+
The rest is as on Docker agents: each step names its job for `notify`'s
|
|
227
|
+
webhooks, `post` sends its email, and the `lock` job's new lock and changes
|
|
228
|
+
are archived as the build's artifacts.
|
|
229
|
+
|
|
230
|
+
The response's `instructions` list what to set up:
|
|
231
|
+
|
|
232
|
+
- Separate namespaces for the two sides.
|
|
233
|
+
- The Kubernetes plugin and its cloud, whose credentials need a Role in the
|
|
234
|
+
namespace with the rights the plugin's own documentation lists: `create`,
|
|
235
|
+
`delete`, `get`, `list`, `patch`, `update` and `watch` on pods, `create`
|
|
236
|
+
and `get` on `pods/exec` (the `container` step), `get`, `list` and `watch`
|
|
237
|
+
on `pods/log`, and `watch` on events. `CLOUD_RULES` in the package holds
|
|
238
|
+
them, and `ACCOUNT_RULES` the service account's below.
|
|
239
|
+
- The `datadouble` claim: `ReadWriteMany`, or `ReadWriteOnce` with the
|
|
240
|
+
runtime's `node` set so every pod runs on that node, owned by the engine's
|
|
241
|
+
user.
|
|
242
|
+
- Each other claim the runtime's `claims` lists, owned by the engine's user.
|
|
243
|
+
- The service account `datadouble-<spec>-<side>` the pods run as, with a Role
|
|
244
|
+
allowing `get`, `list`, `watch`, `create`, `delete` and `patch` on pods,
|
|
245
|
+
`pods/log`, `pods/exec`, `pods/portforward` and Secrets, and `get` and
|
|
246
|
+
`list` on PersistentVolumeClaims; on the non-production side, a
|
|
247
|
+
ClusterRole for PersistentVolumes as well, which the `k8s-pv` replicate
|
|
248
|
+
adapter makes.
|
|
249
|
+
- On the production side, the `datadouble-boundary` ConfigMap, inside the
|
|
250
|
+
production boundary only.
|
|
251
|
+
|
|
252
|
+
The conformance suite runs Kubernetes agents end to end in their own CI job
|
|
253
|
+
(`make test-ci SYSTEM=jenkins-kubernetes`): Jenkins with the plugin, whose
|
|
254
|
+
cloud has exactly `CLOUD_RULES`, runs every job of both sides as a pod on a
|
|
255
|
+
kind cluster, each side in its own namespace from one spec whose runtime
|
|
256
|
+
names none, and each build's pod must hold everything its Jenkinsfile
|
|
257
|
+
declares; each side's engine pods must start in that side's namespace. A
|
|
258
|
+
namespace without the ConfigMap is refused `build`, `promote` and `lock`
|
|
259
|
+
while Jenkins' global environment sets `DATADOUBLE_BOUNDARY=inside`.
|
|
260
|
+
|
|
261
|
+
- **The plugin's agent image** must be one the pods can pull; the suite
|
|
262
|
+
loads `jenkins/inbound-agent` into the cluster and names it to the plugin
|
|
263
|
+
(`PodTemplateStepExecution.defaultImage`).
|
|
264
|
+
- **A finished pod's workspace goes with it,** and the step's outputs are
|
|
265
|
+
in the workspace. The step returns them to the Jenkinsfile; to read them
|
|
266
|
+
from outside, as the suite does, keep finished pods (the cloud's pod
|
|
267
|
+
retention) and read `.datadouble-outputs` from the Datadouble container.
|
|
268
|
+
|
|
269
|
+
## Outcomes
|
|
270
|
+
|
|
271
|
+
| Outcome | The build | The step returns |
|
|
272
|
+
|---|---|---|
|
|
273
|
+
| success | succeeds | `outcome`, `generation` for `run` |
|
|
274
|
+
| warning | unstable | as above |
|
|
275
|
+
| failure | fails | `error`, the error code |
|
|
276
|
+
|
|
277
|
+
The step sets the build's description to the generation it built. Only the
|
|
278
|
+
`lock` job archives build artifacts: its lock and changes, which hold no data
|
|
279
|
+
values.
|
|
280
|
+
|
|
281
|
+
## Notifications
|
|
282
|
+
|
|
283
|
+
The spec's `notify` section configures notifications for jobs that fail,
|
|
284
|
+
warn or recover. Each `datadouble` step names its job (`job: 'build'`), so Datadouble posts the
|
|
285
|
+
spec's webhooks itself after the command, with the build's page
|
|
286
|
+
(`BUILD_URL`, set when Jenkins knows its own URL) as `run_url`. Add the
|
|
287
|
+
webhook's variable as a Secret text credential like the others.
|
|
288
|
+
|
|
289
|
+
`notify`'s email is Jenkins' own `mail` step (the Mailer plugin, with the
|
|
290
|
+
SMTP server set in Manage Jenkins), in the Jenkinsfile's `post` section:
|
|
291
|
+
`failure` and `aborted` (a build stopped at its time limit) for failures,
|
|
292
|
+
`unstable` for warnings, and `fixed` for recoveries. Its subject names the
|
|
293
|
+
build's result (failure, aborted or unstable, or "recovered" for `fixed`),
|
|
294
|
+
and its body adds the build's URL when Jenkins knows it. Jenkins judges
|
|
295
|
+
`fixed` from the previous build: a success after a failed or unstable one,
|
|
296
|
+
not after an aborted one. Because
|
|
297
|
+
`post` runs however the build ended, it also reports a build that failed
|
|
298
|
+
before Datadouble started, such as an image that cannot be pulled, which
|
|
299
|
+
posts no webhook. A notification that cannot be sent, by mail or webhook, is
|
|
300
|
+
logged and leaves the build's result alone.
|
|
301
|
+
|
|
302
|
+
For a recovery webhook, each command line records its last outcome in a
|
|
303
|
+
file `ci init` names (`--ci-record`), under `.datadouble-notify/` in the work
|
|
304
|
+
directory on the production side and in staging on the other. Every
|
|
305
|
+
production Jenkinsfile then mounts the work directory, so it must exist on
|
|
306
|
+
the agent, owned by the engine's user, as for `build`.
|