First Steps with Jenkins and JJB

2 views
Skip to first unread message

Jan-Benedict Glaw

unread,
Jan 25, 2026, 2:46:45 PM (12 days ago) Jan 25
to jenkins-j...@googlegroups.com
Hi!

First of all, I'm just starting to explore Jenkins and Jenkins Job
Builder, so I've not got any previous experience with those.

Right now, I'm running a good number of jobs in Laminar, but I'd
like to have a try with Jenkins as well. I'm doing mass-builds of GCC,
Binutils, GNU libc, Linux kernel, complete NetBSD releases and stuff
like that. Builds are *not* triggered by upstream commits, but I start
them explicitely through Laminar's API (by invoking the `laminarc`
client program.)

Laminar has a nice feature that a job is just a simple script in a
directory. That way, I've created ONE script that eg. builds NetBSD
releases and symlinked it as `netbsd-alpha-alpha`, `netbsd-vax-vax`,
`netbsd-virt68k-m68k` etc., so the actual target information is taken
from the job's name. That seems to match well with `job-template` and
`project`. However, I can also submit variables to the Laminar jobs
(for example, I use a `rev` variable to name a GIT branch or revision
to be build, defaulting to something like `trunk` or `master`, or
`compiler` to choose between the usual system GCC, GCC from the
`gcc-snapshot` package or a super-up-to-date self-built GCC) when I
queue jobs with `larminarc`. How do I implement (and set) such
variables?

For building Docker images (where the actual builds take part),
what's a good strategy there? Create them on one node and copy them to
all others? Is there a chance to also have a job-template/project to
create jobs like `builddocker-gcc`, `builddocker-netbsd`,
`builddocker-linux` etc., but also supply a variable together with the
template variable? So really, what I'd like to have, is basically
something like:

jobs_variants:
- { name: "gcc", "packages": "binutils gcc autoconf automake" }
- { name: "simh", "packages: "binutils gcc libpcap-dev" }

...so that it could generate `dockerbuild-gcc` and `dockerbuild-simh`
(based on `name`), these shall generate Jenkins jobs that create a
docker container for building GCC and OpenSIMH and will supply the
${packages} as a variable to the script so that I can install these
packages.


What I'm currently playing with is something like this:
----------------------------------------------------------
- job-template:
name: netbsd-{target}
description: NetBSD for {target}
builders:
- shell: |
echo foo
echo foo > foo.file
my_target={target}
# Variables are not passed, but files are.
- shell: |
echo {target}
echo ${{my_target}}
my_target={target}
echo ${{my_target}}
ls -l
cat << __EOF__
foo
bar
__EOF__
exit 0

- project:
name: netbsd
target: ['alpha-alpha', 'vax-vax', 'virt68k-m68k']
jobs:
- netbsd-{target}
----------------------------------------------------------

So this boils down to:

* How can I choose the shell to be used for `shell:` commands?

* How do I declare and pass variables into a job (created from a
template), so that, for example, I can build specific GIT
revisions of a project (doing this quite often to bisect
breakages.)

* Can I pass something like a package list to a job (in addition to
job's plain name when using a template)? If not, I'd place a file
in a repo and load the package list from there, but I'd prefer to
have this within the JJB file.

* I failed to see how `archive` works. All my jobs will create some
output directory and I'd like to store/keep whatever is in there.


Thanks a lot,
Jan-Benedict

--
signature.asc

Jan-Benedict Glaw

unread,
Jan 25, 2026, 3:11:37 PM (12 days ago) Jan 25
to jenkins-j...@googlegroups.com
Hi!

So I just found out how I'd handle artifacts:

On Sun, 2026-01-25 20:46:41 +0100, Jan-Benedict Glaw <jbg...@lug-owl.de> wrote:
> * How can I choose the shell to be used for `shell:` commands?
>
> * How do I declare and pass variables into a job (created from a
> template), so that, for example, I can build specific GIT
> revisions of a project (doing this quite often to bisect
> breakages.)
>
> * Can I pass something like a package list to a job (in addition to
> job's plain name when using a template)? If not, I'd place a file
> in a repo and load the package list from there, but I'd prefer to
> have this within the JJB file.


--------------------------------------------------------------------
- job-template:
name: netbsd-{target}
description: NetBSD for {target}
publishers:
- archive:
artifacts: 'outdir/**'
allow-empty-archive: true
builders:
- shell: |
echo foo
echo foo > foo.file
my_target={target}
mkdir -p outdir/subdir
echo some contents > outdir/artifact-file.txt
echo some more contents > outdir/subdir/subdir-artifact-file.txt
# Variables are not passed, but files are.
- shell: |
echo {target}
echo ${{my_target}}
my_target={target}
echo ${{my_target}}
ls -l
cat << __EOF__
foo
bar
__EOF__
exit 0

- project:
name: netbsd
target: ['alpha-alpha', 'vax-vax', 'virt68k-m68k']
jobs:
- netbsd-{target}
--------------------------------------------------------------------

--
signature.asc

Jan-Benedict Glaw

unread,
Jan 25, 2026, 3:29:23 PM (12 days ago) Jan 25
to jenkins-j...@googlegroups.com
Hi!

I really feel silly for looking at that stuff for a day, then asking
for help and instantly finding solutions to (some of) my questions. A
`rev`ision parameter can be done like this:

On Sun, 2026-01-25 21:11:34 +0100, Jan-Benedict Glaw <jbg...@lug-owl.de> wrote:
> On Sun, 2026-01-25 20:46:41 +0100, Jan-Benedict Glaw <jbg...@lug-owl.de> wrote:
> > * How can I choose the shell to be used for `shell:` commands?
> >
> > * Can I pass something like a package list to a job (in addition to
> > job's plain name when using a template)? If not, I'd place a file
> > in a repo and load the package list from there, but I'd prefer to
> > have this within the JJB file.

--------------------------------------------------------------------
- job-template:
name: netbsd-{target}
description: NetBSD for {target}
publishers:
- archive:
artifacts: 'outdir/**'
allow-empty-archive: true
parameters:
- string:
name: rev
default: master
description: "GIT revision to build, defaults to master"
builders:
- shell: |
echo foo
echo foo > foo.file
my_target={target}
mkdir -p outdir/subdir
echo some contents > outdir/artifact-file.txt
echo some more contents > outdir/subdir/subdir-artifact-file.txt
# Variables are not passed, but files are.
- shell: |
echo {target}
echo ${{my_target}}
echo Building for revision ${{rev}}
my_target={target}
echo ${{my_target}}
ls -l
cat << __EOF__
foo
bar
__EOF__
exit 0


- project:
name: netbsd
target: ['alpha-alpha', 'vax-vax', 'virt68k-m68k']
jobs:
- netbsd-{target}
--------------------------------------------------------------------

Thanks,
Jan-Benedict

--
signature.asc

Vsevolod Fedorov

unread,
Jan 26, 2026, 12:40:34 PM (11 days ago) Jan 26
to Jan-Benedict Glaw, jenkins-j...@googlegroups.com

Hi, Jan-Benedict!

I am glad that  you have figured this out.

Just some more suggestions.
You should not mismatch features of JJB and Jenkins itself. First you find out how to do something with Jenkins, then - how to implement this in JJB. JJB is just a template engine for Jenkins.
Also, there are 'static' and 'dynamic' parameters (if you can call them this way): You can produce several jobs from a single template statically using template parameters, or you can have
a job with parameters which are defined at runtime. Latter is your case, as I see.

Also, from my experience, artifacts archival in Jenkins only works normally for small files. For example, texts with job output codes, file paths etc.
Larger files, such as produced from a build, better to upload to some service designed specifically for that. For example, artifactory, nexus, or just some remote NFS.

Reply all
Reply to author
Forward
0 new messages