aboutsummaryrefslogtreecommitdiff
path: root/modules/apps/jenkins
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2018-09-15 15:59:02 +0300
committerIgor Pashev <pashev.igor@gmail.com>2018-09-15 15:59:05 +0300
commitd45a3021ea22eb9d088abf7af27367f6d39b56cf (patch)
tree9c350b7b1d80a3db770fc5b429c32954d10d6ee8 /modules/apps/jenkins
parent22f1d377210266a8389bbe6db5eb49972aa64cc3 (diff)
downloadnixsap-d45a3021ea22eb9d088abf7af27367f6d39b56cf.tar.gz
Support node configuration in Jenkins
Similar to jobs.
Diffstat (limited to 'modules/apps/jenkins')
-rw-r--r--modules/apps/jenkins/default.nix15
-rw-r--r--modules/apps/jenkins/instance.nix9
2 files changed, 24 insertions, 0 deletions
diff --git a/modules/apps/jenkins/default.nix b/modules/apps/jenkins/default.nix
index 42ae197..210a4ea 100644
--- a/modules/apps/jenkins/default.nix
+++ b/modules/apps/jenkins/default.nix
@@ -26,6 +26,7 @@ let
configFiles = name: cfg: mapAttrs (n: v: maybeFile "jenkins-${name}-${n}" v) cfg.config;
jobFiles = name: cfg: mapAttrs (n: v: maybeFile "jenkins-${name}-job-${n}.xml" v) cfg.jobs;
+ nodeFiles = name: cfg: mapAttrs (n: v: maybeFile "jenkins-${name}-node-${n}.xml" v) cfg.nodes;
keyrings =
let
@@ -87,6 +88,20 @@ let
'') (jobFiles name cfg)
)}
+ if [ -d nodes ]; then
+ find nodes -maxdepth 1 -mindepth 1 -type d \
+ ${concatMapStringsSep " " (k: "-not -name '${escape [ "[" ] k}'") (attrNames cfg.nodes)} \
+ -print0 | xargs -0 --verbose --no-run-if-empty rm -rf
+ fi
+
+ ${concatStringsSep "\n" (
+ mapAttrsToList (n: p: ''
+ mkdir -p -- 'nodes/${n}'
+ rm -rf -- 'nodes/${n}/config.xml'
+ ${pkgs.libxml2}/bin/xmllint --xinclude --format '${p}' > 'nodes/${n}/config.xml'
+ '') (nodeFiles name cfg)
+ )}
+
mkdir -p secrets
echo ${if cfg.master-access-control then "false" else "true"} > secrets/slave-to-master-security-kill-switch
diff --git a/modules/apps/jenkins/instance.nix b/modules/apps/jenkins/instance.nix
index 6cca8a4..89c5c93 100644
--- a/modules/apps/jenkins/instance.nix
+++ b/modules/apps/jenkins/instance.nix
@@ -62,6 +62,15 @@ in {
default = true;
};
+ nodes = mkOption {
+ description = ''
+ Nodes. Each value is either inline XML text or an XML file.
+ Any existing nodes, not mentioned here, are physically removed.
+ '';
+ type = attrsOf (either str path);
+ default = {};
+ };
+
jobs = mkOption {
description = ''
Jenkins jobs. Each value is either inline XML text or an XML file.