From d45a3021ea22eb9d088abf7af27367f6d39b56cf Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Sat, 15 Sep 2018 15:59:02 +0300 Subject: Support node configuration in Jenkins Similar to jobs. --- modules/apps/jenkins/default.nix | 15 +++++++++++++++ modules/apps/jenkins/instance.nix | 9 +++++++++ 2 files changed, 24 insertions(+) (limited to 'modules') 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. -- cgit v1.2.3