From eeb3206a29560a6b9ad141b27fa4eec51058e4d7 Mon Sep 17 00:00:00 2001 From: "P. R. d. O" Date: Fri, 1 Apr 2022 12:03:29 -0600 Subject: [PATCH] nixos/jenkinsSlave: install java Installs Java into the Jenkins agent and allows specifying the JDK/JRE package to use. This is necessary as Jenkins verifies if the agent contains Java installed through the java -fullversion command, which if not, the connection will fail. --- .../continuous-integration/jenkins/slave.nix | 16 +++++++++++++++- nixos/tests/jenkins.nix | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/continuous-integration/jenkins/slave.nix b/nixos/modules/services/continuous-integration/jenkins/slave.nix index 3c0e6f78e74c..871b9914fb27 100644 --- a/nixos/modules/services/continuous-integration/jenkins/slave.nix +++ b/nixos/modules/services/continuous-integration/jenkins/slave.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, ... }: with lib; let cfg = config.services.jenkinsSlave; @@ -46,6 +46,15 @@ in { this is the home of the "jenkins" user. ''; }; + + javaPackage = mkOption { + default = pkgs.jdk; + defaultText = literalExpression "pkgs.jdk"; + description = '' + Java package to install. + ''; + type = types.package; + }; }; }; @@ -64,5 +73,10 @@ in { uid = config.ids.uids.jenkins; }; }; + + programs.java = { + enable = true; + package = cfg.javaPackage; + }; }; } diff --git a/nixos/tests/jenkins.nix b/nixos/tests/jenkins.nix index cb4207c6e773..265d1a330cd9 100644 --- a/nixos/tests/jenkins.nix +++ b/nixos/tests/jenkins.nix @@ -90,6 +90,8 @@ import ./make-test-python.nix ({ pkgs, ...} : { slave.fail("systemctl is-enabled jenkins.service") + slave.succeed("java -fullversion") + with subtest("jobs are declarative"): # Check that jobs are created on disk. master.wait_for_unit("jenkins-job-builder")