biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / development / tools / continuous-integration / jenkins / default.nix
blob10f2d9faba12bd4fe05d03c3fa0e6afd97f67469
1 { lib, stdenv, fetchurl, common-updater-scripts, coreutils, git, gnused
2 , makeWrapper, nix, nixfmt-classic, openjdk, writeScript, nixosTests, jq, cacert
3 , curl }:
5 stdenv.mkDerivation rec {
6   pname = "jenkins";
7   version = "2.440.3";
9   src = fetchurl {
10     url = "https://get.jenkins.io/war-stable/${version}/jenkins.war";
11     hash = "sha256-+NR9v9WTWVUa6tg4j6StcAXtp8R84hxmTJlhDKBK42c=";
12   };
14   nativeBuildInputs = [ makeWrapper ];
16   buildCommand = ''
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"
27   '';
29   passthru = {
30     tests = { inherit (nixosTests) jenkins jenkins-cli; };
32     updateScript = writeScript "update.sh" ''
33       #!${stdenv.shell}
34       set -o errexit
35       PATH=${
36         lib.makeBinPath [
37           cacert
38           common-updater-scripts
39           coreutils
40           curl
41           git
42           gnused
43           jq
44           nix
45           nixfmt-classic
46         ]
47       }
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"
60         nixfmt "$default_nix"
61       else
62         echo "jenkins is already up-to-date"
63       fi
64     '';
65   };
67   meta = with lib; {
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;
77   };