Merge branch 'release-21.05' into staging-next-21.05
This brings not that many rebuilds but still some.
This commit is contained in:
@@ -92,7 +92,7 @@ in
|
||||
example = "PCI:4:0:0";
|
||||
description = ''
|
||||
Bus ID of the AMD APU. You can find it using lspci; for example if lspci
|
||||
shows the AMD APU at "04:00.0", set this option to "PCI:4:0:0".
|
||||
shows the AMD APU at "04:00.0", set this option to "PCI:4:0:0".
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -159,7 +159,7 @@ in
|
||||
description = ''
|
||||
The NVIDIA X11 derivation to use.
|
||||
'';
|
||||
example = "config.boot.kernelPackages.nvidiaPackages.legacy340";
|
||||
example = "config.boot.kernelPackages.nvidiaPackages.legacy_340";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -165,6 +165,42 @@ in {
|
||||
'';
|
||||
in
|
||||
''
|
||||
joinByString()
|
||||
{
|
||||
local separator="$1"
|
||||
shift
|
||||
local first="$1"
|
||||
shift
|
||||
printf "%s" "$first" "''${@/#/$separator}"
|
||||
}
|
||||
|
||||
# Map a relative directory path in the output from
|
||||
# jenkins-job-builder (jobname) to the layout expected by jenkins:
|
||||
# each directory level gets prepended "jobs/".
|
||||
getJenkinsJobDir()
|
||||
{
|
||||
IFS='/' read -ra input_dirs <<< "$1"
|
||||
printf "jobs/"
|
||||
joinByString "/jobs/" "''${input_dirs[@]}"
|
||||
}
|
||||
|
||||
# The inverse of getJenkinsJobDir (remove the "jobs/" prefixes)
|
||||
getJobname()
|
||||
{
|
||||
IFS='/' read -ra input_dirs <<< "$1"
|
||||
local i=0
|
||||
local nelem=''${#input_dirs[@]}
|
||||
for e in "''${input_dirs[@]}"; do
|
||||
if [ $((i % 2)) -eq 1 ]; then
|
||||
printf "$e"
|
||||
if [ $i -lt $(( nelem - 1 )) ]; then
|
||||
printf "/"
|
||||
fi
|
||||
fi
|
||||
i=$((i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
rm -rf ${jobBuilderOutputDir}
|
||||
cur_decl_jobs=/run/jenkins-job-builder/declarative-jobs
|
||||
rm -f "$cur_decl_jobs"
|
||||
@@ -172,27 +208,27 @@ in {
|
||||
# Create / update jobs
|
||||
mkdir -p ${jobBuilderOutputDir}
|
||||
for inputFile in ${yamlJobsFile} ${concatStringsSep " " jsonJobsFiles}; do
|
||||
HOME="${jenkinsCfg.home}" "${pkgs.jenkins-job-builder}/bin/jenkins-jobs" --ignore-cache test -o "${jobBuilderOutputDir}" "$inputFile"
|
||||
HOME="${jenkinsCfg.home}" "${pkgs.jenkins-job-builder}/bin/jenkins-jobs" --ignore-cache test --config-xml -o "${jobBuilderOutputDir}" "$inputFile"
|
||||
done
|
||||
|
||||
for file in "${jobBuilderOutputDir}/"*; do
|
||||
test -f "$file" || continue
|
||||
jobname="$(basename $file)"
|
||||
jobdir="${jenkinsCfg.home}/jobs/$jobname"
|
||||
find "${jobBuilderOutputDir}" -type f -name config.xml | while read -r f; do echo "$(dirname "$f")"; done | sort | while read -r dir; do
|
||||
jobname="$(realpath --relative-to="${jobBuilderOutputDir}" "$dir")"
|
||||
jenkinsjobname=$(getJenkinsJobDir "$jobname")
|
||||
jenkinsjobdir="${jenkinsCfg.home}/$jenkinsjobname"
|
||||
echo "Creating / updating job \"$jobname\""
|
||||
mkdir -p "$jobdir"
|
||||
touch "$jobdir/${ownerStamp}"
|
||||
cp "$file" "$jobdir/config.xml"
|
||||
echo "$jobname" >> "$cur_decl_jobs"
|
||||
mkdir -p "$jenkinsjobdir"
|
||||
touch "$jenkinsjobdir/${ownerStamp}"
|
||||
cp "$dir"/config.xml "$jenkinsjobdir/config.xml"
|
||||
echo "$jenkinsjobname" >> "$cur_decl_jobs"
|
||||
done
|
||||
|
||||
# Remove stale jobs
|
||||
for file in "${jenkinsCfg.home}"/jobs/*/${ownerStamp}; do
|
||||
test -f "$file" || continue
|
||||
jobdir="$(dirname $file)"
|
||||
jobname="$(basename "$jobdir")"
|
||||
grep --quiet --line-regexp "$jobname" "$cur_decl_jobs" 2>/dev/null && continue
|
||||
find "${jenkinsCfg.home}" -type f -name "${ownerStamp}" | while read -r f; do echo "$(dirname "$f")"; done | sort --reverse | while read -r dir; do
|
||||
jenkinsjobname="$(realpath --relative-to="${jenkinsCfg.home}" "$dir")"
|
||||
grep --quiet --line-regexp "$jenkinsjobname" "$cur_decl_jobs" 2>/dev/null && continue
|
||||
jobname=$(getJobname "$jenkinsjobname")
|
||||
echo "Deleting stale job \"$jobname\""
|
||||
jobdir="${jenkinsCfg.home}/$jenkinsjobname"
|
||||
rm -rf "$jobdir"
|
||||
done
|
||||
'' + (if cfg.accessUser != "" then reloadScript else "");
|
||||
|
||||
@@ -107,8 +107,15 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs;
|
||||
[ xdotool firefox chromium falkon midori ];
|
||||
environment.systemPackages = with pkgs; [
|
||||
xdotool
|
||||
# Firefox was disabled here, because we needed to disable p11-kit support in nss,
|
||||
# which is why it will not use the system certificate store for the time being.
|
||||
# firefox
|
||||
chromium
|
||||
falkon
|
||||
midori
|
||||
];
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
@@ -145,7 +152,14 @@ in
|
||||
with subtest("Unknown CA is untrusted in curl"):
|
||||
machine.fail("curl -fv https://bad.example.com")
|
||||
|
||||
browsers = ["firefox", "chromium", "falkon", "midori"]
|
||||
browsers = [
|
||||
# Firefox was disabled here, because we needed to disable p11-kit support in nss,
|
||||
# which is why it will not use the system certificate store for the time being.
|
||||
# "firefox",
|
||||
"chromium",
|
||||
"falkon",
|
||||
"midori"
|
||||
]
|
||||
errors = ["Security Risk", "not private", "Certificate Error", "Security"]
|
||||
|
||||
machine.wait_for_x()
|
||||
|
||||
+83
-2
@@ -2,6 +2,7 @@
|
||||
# 1. jenkins service starts on master node
|
||||
# 2. jenkins user can be extended on both master and slave
|
||||
# 3. jenkins service not started on slave node
|
||||
# 4. declarative jobs can be added and removed
|
||||
|
||||
import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
name = "jenkins";
|
||||
@@ -13,7 +14,45 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
|
||||
master =
|
||||
{ ... }:
|
||||
{ services.jenkins.enable = true;
|
||||
{ services.jenkins = {
|
||||
enable = true;
|
||||
jobBuilder = {
|
||||
enable = true;
|
||||
nixJobs = [
|
||||
{ job = {
|
||||
name = "job-1";
|
||||
builders = [
|
||||
{ shell = ''
|
||||
echo "Running job-1"
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
{ job = {
|
||||
name = "folder-1";
|
||||
project-type = "folder";
|
||||
};
|
||||
}
|
||||
|
||||
{ job = {
|
||||
name = "folder-1/job-2";
|
||||
builders = [
|
||||
{ shell = ''
|
||||
echo "Running job-2"
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
specialisation.noJenkinsJobs.configuration = {
|
||||
services.jenkins.jobBuilder.nixJobs = pkgs.lib.mkForce [];
|
||||
};
|
||||
|
||||
# should have no effect
|
||||
services.jenkinsSlave.enable = true;
|
||||
@@ -32,7 +71,12 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
testScript = { nodes, ... }:
|
||||
let
|
||||
configWithoutJobs = "${nodes.master.config.system.build.toplevel}/specialisation/noJenkinsJobs";
|
||||
jenkinsPort = nodes.master.config.services.jenkins.port;
|
||||
jenkinsUrl = "http://localhost:${toString jenkinsPort}";
|
||||
in ''
|
||||
start_all()
|
||||
|
||||
master.wait_for_unit("jenkins")
|
||||
@@ -45,5 +89,42 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
assert "users" in groups
|
||||
|
||||
slave.fail("systemctl is-enabled jenkins.service")
|
||||
|
||||
with subtest("jobs are declarative"):
|
||||
# Check that jobs are created on disk.
|
||||
master.wait_for_unit("jenkins-job-builder")
|
||||
master.wait_until_fails("systemctl is-active jenkins-job-builder")
|
||||
master.wait_until_succeeds("test -f /var/lib/jenkins/jobs/job-1/config.xml")
|
||||
master.wait_until_succeeds("test -f /var/lib/jenkins/jobs/folder-1/config.xml")
|
||||
master.wait_until_succeeds("test -f /var/lib/jenkins/jobs/folder-1/jobs/job-2/config.xml")
|
||||
|
||||
# Wait until jenkins is ready, reload configuration and verify it also
|
||||
# sees the jobs.
|
||||
master.succeed("curl --fail ${jenkinsUrl}/cli")
|
||||
master.succeed("curl ${jenkinsUrl}/jnlpJars/jenkins-cli.jar -O")
|
||||
master.succeed("${pkgs.jre}/bin/java -jar jenkins-cli.jar -s ${jenkinsUrl} -auth admin:$(cat /var/lib/jenkins/secrets/initialAdminPassword) reload-configuration")
|
||||
out = master.succeed("${pkgs.jre}/bin/java -jar jenkins-cli.jar -s ${jenkinsUrl} -auth admin:$(cat /var/lib/jenkins/secrets/initialAdminPassword) list-jobs")
|
||||
jobs = [x.strip() for x in out.splitlines()]
|
||||
# Seeing jobs inside folders requires the Folders plugin
|
||||
# (https://plugins.jenkins.io/cloudbees-folder/), which we don't have
|
||||
# in this vanilla jenkins install, so limit ourself to non-folder jobs.
|
||||
assert jobs == ['job-1'], f"jobs != ['job-1']: {jobs}"
|
||||
|
||||
master.succeed(
|
||||
"${configWithoutJobs}/bin/switch-to-configuration test >&2"
|
||||
)
|
||||
|
||||
# Check that jobs are removed from disk.
|
||||
master.wait_for_unit("jenkins-job-builder")
|
||||
master.wait_until_fails("systemctl is-active jenkins-job-builder")
|
||||
master.wait_until_fails("test -f /var/lib/jenkins/jobs/job-1/config.xml")
|
||||
master.wait_until_fails("test -f /var/lib/jenkins/jobs/folder-1/config.xml")
|
||||
master.wait_until_fails("test -f /var/lib/jenkins/jobs/folder-1/jobs/job-2/config.xml")
|
||||
|
||||
# Reload jenkins' configuration and verify it also sees the jobs as removed.
|
||||
master.succeed("${pkgs.jre}/bin/java -jar jenkins-cli.jar -s ${jenkinsUrl} -auth admin:$(cat /var/lib/jenkins/secrets/initialAdminPassword) reload-configuration")
|
||||
out = master.succeed("${pkgs.jre}/bin/java -jar jenkins-cli.jar -s ${jenkinsUrl} -auth admin:$(cat /var/lib/jenkins/secrets/initialAdminPassword) list-jobs")
|
||||
jobs = [x.strip() for x in out.splitlines()]
|
||||
assert jobs == [], f"jobs != []: {jobs}"
|
||||
'';
|
||||
})
|
||||
|
||||
@@ -31,7 +31,6 @@ with pkgs; {
|
||||
linux_4_19 = makeKernelTest "4.19" linuxPackages_4_19;
|
||||
linux_5_4 = makeKernelTest "5.4" linuxPackages_5_4;
|
||||
linux_5_10 = makeKernelTest "5.10" linuxPackages_5_10;
|
||||
linux_5_11 = makeKernelTest "5.11" linuxPackages_5_11;
|
||||
linux_5_12 = makeKernelTest "5.12" linuxPackages_5_12;
|
||||
|
||||
linux_testing = makeKernelTest "testing" linuxPackages_testing;
|
||||
|
||||
Reference in New Issue
Block a user