Describe your use-case which is not covered by existing documentation.
Hi there ๐
I have started to modify the documentation in the hope of submitting a PR shortly.
I am using docker
as it is the only supported platform.
Following the existing documentation, after setting the WAR
and JENKINS_URL
environment variables
(not necessary if I read correctly the docker-compose.yaml
|
- "WAR=/srv/releases/jenkins/jenkins.war" |
, I launch ./prep.sh
. Unfortunately, ./prep.sh
does not work for me inside this container:
jenkins@420db984a78b:/srv/releases/jenkins$ ./prep.sh
: invalid option
make setup
does not work either with the same kind of error:
make setup
bash -ex -c 'for f in */setup.sh; do $f; done'
+ for f in */setup.sh
+ deb/setup.sh
: invalid option
make: *** [Makefile:24: setup] Error 1
bash -x prep.sh
outputs:
+ set -o $'pipefail\r'
: invalid option name pipefail
++ dirname prep.sh
+ cd $'.\r'
prep.sh: line 3: cd: $'.\r': No such file or directory
+ $'\r'
prep.sh: line 4: $'\r': command not found
+ $'\r'
prep.sh: line 10: $'\r': command not found
prep.sh: line 21: syntax error: unexpected end of file
Apparently, pipefail
is a bashism, but we're using bash
, aren't we? Furthermore, are these files Windows encoded?
I would have like to debug by modifying the script files, but there is no editor bundled in the image (as far as I know).
Would anyone have a hint to get me out of the rut?
Here is the complete set of environment variables, just in case:
BASH=/usr/bin/bash
BASHOPTS=checkwinsize:cmdhist:complete_fullquote:expand_aliases:extquote:force_fignore:globasciiranges:histappend:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=([0]="0")
BASH_ARGV=()
BASH_CMDS=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="5" [1]="1" [2]="16" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu")
BASH_VERSION='5.1.16(1)-release'
BRAND=/srv/releases/jenkins/branding/jenkins.mk
BRANDING_DIR=/srv/releases/jenkins/branding
BUILDENV=/srv/releases/jenkins/env/test.mk
COLUMNS=230
DEBIAN_FRONTEND=noninteractive
DIRSTACK=()
EUID=1000
GPG_FILE=/srv/releases/jenkins/credentials/sandbox.gpg
GPG_KEYNAME=551F7B8423F34E8A1E9EEE1B3DD66EC9C147FCD1
GPG_PASSPHRASE=s3cr3t
GPG_PASSPHRASE_FILE=/srv/releases/jenkins/credentials/test.gpg.password.txt
GROUPS=()
HISTCONTROL=ignoreboth
HISTFILE=/home/jenkins/.bash_history
HISTFILESIZE=2000
HISTSIZE=1000
HOME=/home/jenkins
HOSTNAME=420db984a78b
HOSTTYPE=x86_64
IFS=$' \t\n'
JAVA_HOME=/opt/jdk-8
JENKINS_URL=http://192.168.0.144:8080/
LANG=C.UTF-8
LINES=66
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:'
MACHTYPE=x86_64-pc-linux-gnu
MAILCHECK=60
MSI=/srv/releases/jenkins/jenkins.msi
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/opt/jdk-8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PIPESTATUS=([0]="0")
PPID=0
PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
PS2='> '
PS4='+ '
PWD=/srv/releases/jenkins
RELEASELINE=-experimental
SHELL=/bin/sh
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=1
TERM=xterm
TZ=UTC
UID=1000
USER=jenkins
WAR=/srv/releases/jenkins/jenkins.war
Thanks.
Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.
Native package script for Jenkins
This repository contains scripts for packaging jenkins.war
into various platform-specific native packages.
The following platforms are currently supported:
- Windows MSI:
msi/
- RedHat/CentOS RPM:
rpm/
- Debian/Ubuntu DEB:
deb/
- OpenSUSE RPM:
suse/
Pre-requisites
Running the main package script requires a Ubuntu Linux 18.04 environment (see JENKINS-27744.)
Remark:
A docker image is available to run the following scripts. It's the only supported environment.
Run docker-compose run --rm packaging bash
to get a shell in the official Docker image for this repository.
Workaround
If your machine doesn't run this mandatory version of Ubuntu Linux, you can use these scripts within a VM or with the provided Docker image.
The use of the Docker image is not compulsory but any other environment is not supported.
Run make setup
to install (most of the) necessary tools. Alternatively you can manually install the following onto a base install of Ubuntu:
- make
- unzip
- devscripts
- debhelper
- rpm
- expect
- createrepo
- ruby
- net-sftp (
gem install net-sftp
)
- maven
- java
You will also need a Jenkins instance with dist-fork plugin
installed. The URL of this Jenkins can be fed into make
via the JENKINS_URL
variable.
If you want to package for Windows, this Jenkins controller needs to have a Windows build agent that has WiX Toolset (currently 3.5), msbuild, cygwin and .net 2.0. This build agent is used to build MSI packages, which
can be only built on Windows.
You'll also need:
- a
jenkins.war
file that you are packaging, which comes from the release process.
The location of this file is set via the WAR
variable.
- a
jenkins.msi
file if you are packaging for Windows, which also comes from the release process.
Download and reference `jenkins.war`
curl https://get.jenkins.io/war-stable/2.332.3/jenkins.war --output jenkins.war
# or jv download
export WAR=/srv/releases/jenkins/jenkins.war
# if you want to build for windows
curl https://get.jenkins.io/windows-stable/2.332.3/jenkins.msi --output jenkins.msi
export MSI=/srv/releases/jenkins/jenkins.msi
Generating packages
Run ./prep.sh
to perform the preparatory actions of downloading the WAR and importing the GPG key.
Run make package
to build all the native packages.
At minimum, you have to specify the WAR
variable that points to the war file to be packaged and a branding file (for licensing and package descriptions).
You will probably need to pass in the build environment and credentials.
For example:
make package BRAND=./branding/jenkins.mk BUILDENV=./env/test.mk CREDENTIAL=./credentials/test.mk
Packages will be placed into target/
directory.
See the definition of the package
goal for how to build individual packages selectively.
Running functional tests
The functional tests require Python 3 and Docker.
Having built the packages as described above, run the functional tests with:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
molecule test
deactivate
Publishing packages
This repository contains scripts for copying packages over to a remote web server to publish them.
Run make publish
to publish all native packages.
See the definition of the publish
goal for individual package publishment.
Running local tests
These tests install packages from a web server where they are published. So if you want to
run tests prior to publishing them, you need to create a temporary web server that you can mess up.
The default branding & environment (branding/test.mk
and env/test.mk
) are designed to support
this scenario. To make local testing work, you also need to have /etc/hosts
entry that maps
test.pkg.jenkins.io
hostname to 127.0.0.1
, and your computer has to be running ssh that
lets you login as you.
Once you verified the above prerequisites, open another terminal and run make test.local.setup
This will run a docker container that acts as your throw-away package web server. When done, Ctrl+C
to kill it.
Branding
branding/
directory contains *.mk
files that control the branding of the generated packages.
It also include text files which are used for large, branded text blocks (license and descriptions).
Specify the branding file via the BRAND
variable.
You can create your own branding definition to customize the package generation process.
See branding readme for more details. In the rest of the packaging script files,
these branding parameters are referenced via @@NAME@@
and get substituted by bin/branding.py
.
To escape a string normally like @@value@@, add an additional two @@ symbols as a prefix: @@@@value@@.
Environment
env/
directory contains *.mk
files that control the environment into which
you publish packages. Specify the environment file via the BUILDENV
variable.
You can create your own environment definition to customize the package generation process.
See environment readme for more details.
Credentials
credentials/
directory contains test.mk
file that controls the locations of code-signing keys,
their passwords, and certificates. Specify the credentials file via the CREDENTIAL
variable.
For production use, you need to create your own credentials file. See credentials readme
for more details.
TODO (mostly note to myself)
- Split resource templates to enable customization