1 { lib, stdenv, fetchurl, common-updater-scripts, coreutils, git, gnused
2 , makeWrapper, nix, nixfmt-classic, openjdk, writeScript, nixosTests, jq, cacert
5 stdenv.mkDerivation rec {
10 url = "https://get.jenkins.io/war-stable/${version}/jenkins.war";
11 hash = "sha256-+NR9v9WTWVUa6tg4j6StcAXtp8R84hxmTJlhDKBK42c=";
14 nativeBuildInputs = [ makeWrapper ];
17 mkdir -p "$out/bin" "$out/share" "$out/webapps"
19 cp "$src" "$out/webapps/jenkins.war"
21 # Create the `jenkins-cli` command.
22 ${openjdk}/bin/jar -xf "$src" WEB-INF/lib/cli-${version}.jar \
23 && mv WEB-INF/lib/cli-${version}.jar "$out/share/jenkins-cli.jar"
25 makeWrapper "${openjdk}/bin/java" "$out/bin/jenkins-cli" \
26 --add-flags "-jar $out/share/jenkins-cli.jar"
30 tests = { inherit (nixosTests) jenkins jenkins-cli; };
32 updateScript = writeScript "update.sh" ''
38 common-updater-scripts
49 core_json="$(curl -s --fail --location https://updates.jenkins.io/stable/update-center.actual.json | jq .core)"
50 oldVersion=$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion jenkins" | tr -d '"')
52 version="$(jq -r .version <<<$core_json)"
53 sha256="$(jq -r .sha256 <<<$core_json)"
54 hash="$(nix hash to-sri --type sha256 "$sha256")"
56 if [ ! "$oldVersion" = "$version" ]; then
57 update-source-version jenkins "$version" "$hash"
58 nixpkgs="$(git rev-parse --show-toplevel)"
59 default_nix="$nixpkgs/pkgs/development/tools/continuous-integration/jenkins/default.nix"
62 echo "jenkins is already up-to-date"
68 description = "An extendable open source continuous integration server";
69 homepage = "https://jenkins.io/";
70 sourceProvenance = with sourceTypes; [ binaryBytecode ];
71 license = licenses.mit;
72 maintainers = with maintainers;
73 [ coconnor earldouglas nequissimus ] ++ teams.helsinki-systems.members;
74 changelog = "https://www.jenkins.io/changelog-stable/#v${version}";
75 mainProgram = "jenkins-cli";
76 platforms = platforms.all;