diff options
author | Franz Pletz <fpletz@fnordicwalking.de> | 2021-07-06 14:45:29 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-06 14:45:29 +0000 |
commit | f73efb9fb359f4cbdabab93c1a2397bbde77e555 (patch) | |
tree | 92e8383fe4e3159933c64829e950bbb104d6d744 /nixos/modules | |
parent | eea558539e26ac8dfa62a276194650d08eb74c2a (diff) | |
parent | 4f093b8fdb3e6b7102ad99089712beca2ae49abb (diff) |
Merge pull request #121841 from Pamplemousse/jenkins-cli
jenkins: Create the `jenkins-cli` command
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/services/continuous-integration/jenkins/default.nix | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/nixos/modules/services/continuous-integration/jenkins/default.nix b/nixos/modules/services/continuous-integration/jenkins/default.nix index cdc3b4b5c58f5..889688a26853e 100644 --- a/nixos/modules/services/continuous-integration/jenkins/default.nix +++ b/nixos/modules/services/continuous-integration/jenkins/default.nix @@ -2,6 +2,7 @@ with lib; let cfg = config.services.jenkins; + jenkinsUrl = "http://${cfg.listenAddress}:${toString cfg.port}${cfg.prefix}"; in { options = { services.jenkins = { @@ -141,14 +142,34 @@ in { Additional command line arguments to pass to the Java run time (as opposed to Jenkins). ''; }; + + withCLI = mkOption { + type = types.bool; + default = false; + description = '' + Whether to make the CLI available. + + More info about the CLI available at + <link xlink:href="https://www.jenkins.io/doc/book/managing/cli"> + https://www.jenkins.io/doc/book/managing/cli</link> . + ''; + }; }; }; config = mkIf cfg.enable { - # server references the dejavu fonts - environment.systemPackages = [ - pkgs.dejavu_fonts - ]; + environment = { + # server references the dejavu fonts + systemPackages = [ + pkgs.dejavu_fonts + ] ++ optional cfg.withCLI cfg.package; + + variables = {} + // optionalAttrs cfg.withCLI { + # Make it more convenient to use the `jenkins-cli`. + JENKINS_URL = jenkinsUrl; + }; + }; users.groups = optionalAttrs (cfg.group == "jenkins") { jenkins.gid = config.ids.gids.jenkins; @@ -215,7 +236,7 @@ in { ''; postStart = '' - until [[ $(${pkgs.curl.bin}/bin/curl -L -s --head -w '\n%{http_code}' http://${cfg.listenAddress}:${toString cfg.port}${cfg.prefix} | tail -n1) =~ ^(200|403)$ ]]; do + until [[ $(${pkgs.curl.bin}/bin/curl -L -s --head -w '\n%{http_code}' ${jenkinsUrl} | tail -n1) =~ ^(200|403)$ ]]; do sleep 1 done ''; |