Skip to content

Commit 2b5e64a

Browse files
authored
Merge pull request #728 from lemeurherve/stable-2.541
Backport of packaging in `stable-2.541` for LTS 2.541.1
2 parents 3ee2adf + 5f2a9b3 commit 2b5e64a

File tree

19 files changed

+154
-681
lines changed

19 files changed

+154
-681
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ generated
99
.iml
1010
.idea/
1111
*.orig
12+
*.war
13+
*.war.asc
14+
*.sha256
1215

1316
venv/
1417
pkg.jenkins.io/
18+
jenkins.io.key

Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,3 @@ ${CLI}:
5656
@mkdir ${TARGET} || true
5757
wget -O $@.tmp ${JENKINS_URL}jnlpJars/jenkins-cli.jar
5858
mv $@.tmp $@
59-
60-
61-
62-
test.local.setup:
63-
# start a test Apache server that acts as package server
64-
# we'll refer to this as 'test.pkg.jenkins.io'
65-
@mkdir -p ${TESTDIR} || true
66-
docker run --rm -t -i -p 9200:80 -v ${TESTDIR}:/var/www/html fedora/apache

README.md

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,24 @@ The following platforms are currently supported:
77
* RedHat/CentOS/openSUSE RPM: `rpm/`
88
* Debian/Ubuntu DEB: `deb/`
99

10-
# Pre-requisites
10+
## Pre-requisites
11+
12+
### Easy Method
13+
14+
If you are able to run Docker containers with `docker compose` (usually Docker Desktop is enough),
15+
then you can use the same environment as the Jenkins infrastructure production:
16+
17+
```bash
18+
# Start the setup (2 containers: one for packaging and another for a webserver)
19+
docker compose up -d
20+
21+
# Spawn an interactive terminal in the packaging environment (with all dependencies)
22+
docker compose exec packaging bash
23+
# You can run all the `make` command and even `prep.sh` script - see sections below
24+
```
25+
26+
### Container-less Method (aka "The Hard Way")
27+
1128
Running the main package script requires a Linux environment (currently Ubuntu, see [JENKINS-27744](https://issues.jenkins-ci.org/browse/JENKINS-27744).)
1229
Run `make setup` to install (most of the) necessary tools. Alternatively you can manually install the following onto a base install of Ubuntu:
1330
* make
@@ -24,21 +41,11 @@ Run `make setup` to install (most of the) necessary tools. Alternatively you ca
2441

2542
You also need a Jenkins instance with [dist-fork plugin](https://wiki.jenkins-ci.org/display/JENKINS/DistFork+Plugin)
2643
installed. URL of this Jenkins can be fed into `make` via the `JENKINS_URL` variable.
27-
This Jenkins needs to have a Windows build agent that has [WiX Toolset](http://wixtoolset.org/) (currently 3.5), msbuild, [cygwin](https://www.cygwin.com/) and .net 2.0. This build agent is used to build MSI packages, which
28-
can be only built on Windows.
29-
30-
You'll also need a `jenkins.war` file that you are packaging, which comes from the release process.
31-
The location of this file is set via the `WAR` variable.
32-
33-
Remark:
44+
This Jenkins needs to have a Windows build agent that has [WiX Toolset](http://wixtoolset.org/) (currently 3.5), msbuild, [cygwin](https://www.cygwin.com/) and .net 2.0.
45+
This build agent is used to build MSI packages, which can be only built on Windows.
3446

35-
A docker image is available to run following script
47+
## Generating packages
3648

37-
[![logo](https://img.shields.io/docker/pulls/jenkinsciinfra/packaging?label=jenkinsciinfra%2Fpackaging&logo=docker&logoColor=white)](https://hub.docker.com/r/jenkinsciinfra/packaging)
38-
39-
Run `docker-compose run --rm packaging bash` to get a shell in the official Docker image for this repository.
40-
41-
# Generating packages
4249
Run `./prep.sh` to perform the preparatory actions of downloading the WAR and importing the GPG key.
4350
Run `make package` to build all the native packages.
4451
At minimum, you have to specify the `WAR` variable that points to the war file to be packaged and the `BRAND` variable that points to the branding file for licensing, artifact names, and package descriptions.
@@ -53,7 +60,7 @@ make package BRAND=./branding/jenkins.mk BUILDENV=./env/test.mk CREDENTIAL=./cre
5360
Packages will be placed into `target/` directory.
5461
See the definition of the `package` goal for how to build individual packages selectively.
5562

56-
# Running functional tests
63+
## Running functional tests
5764

5865
The functional tests require Python 3 and Docker.
5966
Having built the packages as described above, run the functional tests with:
@@ -66,26 +73,27 @@ molecule test
6673
deactivate
6774
```
6875

69-
# Publishing packages
76+
## Publishing packages
77+
7078
This repository contains scripts for copying packages over to a remote web server to publish them.
7179
Run `make publish` to publish all native packages.
7280

73-
See the definition of the `publish` goal for individual package publishment.
81+
See the definition of the `publish` goal for individual package publication.
7482

7583
## Running local tests
84+
7685
These tests install packages from a web server where they are published. So if you want to
7786
run tests prior to publishing them, you need to create a temporary web server that you can mess up.
7887

7988
The default branding & environment (`branding/test.mk` and `env/test.mk`) are designed to support
8089
this scenario. To make local testing work, you also need to have `/etc/hosts` entry that maps
81-
`test.pkg.jenkins.io` hostname to `127.0.0.1`, and your computer has to be running ssh that
82-
lets you login as you.
90+
`test.pkg.jenkins.io` hostname to `127.0.0.1`.
8391

84-
Once you verified the above prerequisites, open another terminal and run `make test.local.setup`
85-
This will run a docker container that acts as your throw-away package web server. When done, Ctrl+C
86-
to kill it.
92+
Once you verified the above prerequisites, open another terminal and run `docker compose up -d pkgserver`
93+
This will run a docker container that acts as your throw-away package web server.
94+
95+
## Branding
8796

88-
# Branding
8997
`branding/` directory contains `*.mk` files that control the branding of the generated packages.
9098
It also include text files which are used for large, branded text blocks (license and descriptions).
9199
Specify the branding file via the `BRAND` variable.
@@ -95,19 +103,18 @@ See [branding readme](branding/README.md) for more details. In the rest of the p
95103
these branding parameters are referenced via `@@NAME@@` and get substituted by `bin/branding.py`.
96104
To escape a string normally like @@VALUE@@, add an additional two @@ symbols as a prefix: @@@@VALUE@@.
97105

98-
# Environment
106+
## Environment
107+
99108
`env/` directory contains `*.mk` files that control the environment into which
100109
you publish packages. Specify the environment file via the `BUILDENV` variable.
101110

102111
You can create your own environment definition to customize the package generation process.
103112
See [environment readme](env/README.md) for more details.
104113

105-
# Credentials
114+
## Credentials
115+
106116
`credentials/` directory contains `test.mk` file that controls the locations of code-signing keys,
107117
their passwords, and certificates. Specify the credentials file via the `CREDENTIAL` variable.
108118

109119
For production use, you need to create your own credentials file. See [credentials readme](credentials/README.md)
110120
for more details.
111-
112-
# TODO (mostly note to myself)
113-
* Split resource templates to enable customization

bin/indexGenerator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def __init__(self, argv):
6060
self.product_name = os.getenv("PRODUCTNAME", "Jenkins")
6161
self.distribution = os.getenv("OS_FAMILY", "debian")
6262
self.gpg_pub_key_info_file = os.getenv("GPGPUBKEYINFO", ".")
63+
self.gpg_public_key_filename = os.getenv("GPG_PUBLIC_KEY_FILENAME", "jenkins.io.key")
6364
self.target_directory = "./target/" + self.distribution
6465

6566
try:
@@ -107,6 +108,7 @@ def show_information(self):
107108
print("Root header generated: " + self.root_header)
108109
print("Root footer generated: " + self.root_footer)
109110
print("GPG Key Info File: " + self.gpg_pub_key_info_file)
111+
print("GPG Public Key Filename: " + self.gpg_public_key_filename)
110112

111113
def generate_root_header(self):
112114

@@ -169,6 +171,7 @@ def generate_repository_header(self):
169171
"releaseline": self.releaseline,
170172
"web_url": self.web_url,
171173
"pub_key_info": self.fetch_pubkeyinfo(),
174+
"gpg_public_key_filename": self.gpg_public_key_filename,
172175
}
173176

174177
env = jinja2.Environment(
@@ -192,6 +195,7 @@ def generate_repository_index(self):
192195
"releaseline": self.releaseline,
193196
"web_url": self.web_url,
194197
"pub_key_info": self.fetch_pubkeyinfo(),
198+
"gpg_public_key_filename": self.gpg_public_key_filename,
195199
}
196200

197201
env = jinja2.Environment(

credentials/ssh/id_rsa

Lines changed: 0 additions & 27 deletions
This file was deleted.

credentials/ssh/id_rsa.pub

Lines changed: 0 additions & 1 deletion
This file was deleted.

credentials/ssh/known_hosts

Lines changed: 0 additions & 2 deletions
This file was deleted.

deb/publish/contents/binary/.htaccess

Lines changed: 0 additions & 1 deletion
This file was deleted.

deb/publish/publish.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set -euxo pipefail
88
: "${DEBDIR:? Require where to put binary files}"
99
: "${DEB_WEBDIR:? Require where to put repository index and other web contents}"
1010
: "${DEB_URL:? Require Debian repository Url}"
11+
: "${GPG_PUBLIC_KEY_FILENAME:="${ORGANIZATION}.key"}"
1112

1213
# $$ Contains current pid
1314
D="$AGENT_WORKDIR/$$"
@@ -20,14 +21,14 @@ function clean() {
2021

2122
# Generate and publish site content
2223
function generateSite() {
23-
cp -R "$bin/contents/." "$D/contents"
24-
25-
gpg --export -a --output "$D/contents/${ORGANIZATION}.key" "${GPG_KEYNAME}"
26-
gpg --import-options show-only --import "$D/contents/${ORGANIZATION}.key" >"$D/contents/${ORGANIZATION}.key.info"
24+
local gpg_publickey_file="$D/contents/${GPG_PUBLIC_KEY_FILENAME}"
25+
local gpg_publickey_info_file="$D/contents/${GPG_PUBLIC_KEY_FILENAME}.info"
26+
gpg --export -a --output "${gpg_publickey_file}" "${GPG_KEYNAME}"
27+
gpg --import-options show-only --import "${gpg_publickey_file}" > "${gpg_publickey_info_file}"
2728

2829
"$BASE/bin/indexGenerator.py" \
2930
--distribution debian \
30-
--gpg-key-info-file "${D}/contents/${ORGANIZATION}.key.info" \
31+
--gpg-key-info-file "${gpg_publickey_info_file}" \
3132
--targetDir "$D/html"
3233

3334
"$BASE/bin/branding.py" "$D"
@@ -59,7 +60,7 @@ function generateSite() {
5960
}
6061

6162
function init() {
62-
mkdir -p "$D/binary" "$D/contents" "$D/html" \
63+
mkdir -p "$D/binary" "$D/contents" "$D/html" "$D/contents/binary" \
6364
"$DEBDIR" `# where to put binary files` \
6465
"$DEB_WEBDIR" `# where to put repository index and other web contents`
6566
}
@@ -87,14 +88,10 @@ function uploadPackageSite() {
8788
}
8889

8990
function uploadHtmlSite() {
90-
# Html file need to be located in the binary directory
9191
rsync --archive \
9292
--verbose \
9393
--progress \
94-
--include "HEADER.html" \
95-
--include "FOOTER.html" \
96-
--exclude "*" \
97-
"$D/html/" "$DEBDIR/"
94+
"$D/html/" "$DEB_WEBDIR/"
9895
}
9996

10097
function show() {
@@ -103,6 +100,7 @@ function show() {
103100
echo "DEBDIR: $DEBDIR"
104101
echo "DEB_WEBDIR: $DEB_WEBDIR"
105102
echo "GPG_KEYNAME: $GPG_KEYNAME"
103+
echo "GPG_PUBLIC_KEY_FILENAME: $GPG_PUBLIC_KEY_FILENAME"
106104
echo "---"
107105
}
108106

docker-compose.yaml

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# docker exec -i -t packaging_packaging_1 gpg --import --batch credentials/sandbox.gpg
2-
version: '3'
3-
volumes:
4-
sshd:
5-
pkgserver:
1+
# docker compose exec packaging gpg --import --batch credentials/sandbox.gpg
62
services:
73
packaging:
84
image: jenkinsciinfra/packaging:latest
9-
command: "sleep 99d"
5+
platform: linux/amd64
6+
entrypoint:
7+
- "sleep"
8+
- "99d"
109
environment:
1110
- "BUILDENV=/srv/releases/jenkins/env/test.mk"
1211
- "BRANDING_DIR=/srv/releases/jenkins/branding"
@@ -19,25 +18,13 @@ services:
1918
- "MSI=/srv/releases/jenkins/jenkins.msi"
2019
- "RELEASELINE=-experimental"
2120
volumes:
22-
- ".:/srv/releases/jenkins:z"
23-
- "./credentials/ssh:/home/jenkins/.ssh:z"
24-
working_dir: "/srv/releases/jenkins"
25-
26-
remote:
27-
image: jenkinsciinfra/packaging:latest
28-
user: root # In order to start, sshd needs to be root
29-
command: "/usr/sbin/sshd -D"
30-
ports:
31-
- "2222:22"
32-
volumes:
33-
- "./credentials/ssh/id_rsa.pub:/home/jenkins/.ssh/authorized_keys:ro"
34-
- sshd:/run/sshd
35-
- "pkgserver:/srv/releases/jenkins"
21+
- .:/srv/releases/jenkins:z
22+
working_dir: /srv/releases/jenkins
3623

3724
pkgserver:
38-
image: httpd
25+
image: nginx
3926
ports:
4027
- "80:80"
4128
volumes:
42-
- "./pkgConfig/httpd.conf:/usr/local/apache2/conf/httpd.conf"
43-
- "./target:/usr/local/apache2/htdocs"
29+
- ./target:/usr/share/nginx/html:ro
30+
- ./pkgserver/nginx-default-vhost.conf:/etc/nginx/conf.d/default.conf:ro

0 commit comments

Comments
 (0)