From 6a9a87c988a8f229de33afe795fb02cf38735a0f Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Sat, 6 Apr 2019 13:41:29 -0400 Subject: [PATCH] jenkins: Improve update.sh Auto-commit and only run if nixpkgs version is old --- .../tools/continuous-integration/jenkins/update.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkgs/development/tools/continuous-integration/jenkins/update.sh b/pkgs/development/tools/continuous-integration/jenkins/update.sh index e8b6d9257758..66d1b4ceff66 100755 --- a/pkgs/development/tools/continuous-integration/jenkins/update.sh +++ b/pkgs/development/tools/continuous-integration/jenkins/update.sh @@ -3,11 +3,20 @@ set -eu -o pipefail -core_json="$(curl --fail --location https://updates.jenkins.io/stable/update-center.actual.json | jq .core)" +core_json="$(curl -s --fail --location https://updates.jenkins.io/stable/update-center.actual.json | jq .core)" +oldVersion=$(nix-instantiate --eval -E "with import ./. {}; jenkins.version or (builtins.parseDrvName jenkins.name).version" | tr -d '"') version="$(jq -r .version <<<$core_json)" sha256="$(jq -r .sha256 <<<$core_json)" hash="$(nix-hash --type sha256 --to-base32 "$sha256")" url="$(jq -r .url <<<$core_json)" -update-source-version jenkins "$version" "$hash" "$url" +if [ ! "${oldVersion}" = "${version}" ]; then + update-source-version jenkins "$version" "$hash" "$url" + nixpkgs="$(git rev-parse --show-toplevel)" + default_nix="$nixpkgs/pkgs/development/tools/continuous-integration/jenkins/default.nix" + git add "${default_nix}" + git commit -m "jenkins: ${oldVersion} -> ${version}" +else + echo "jenkins is already up-to-date" +fi