From 78066b7a6cc3f55e49d2a1023937dedbf7ff2cd4 Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Mon, 2 Jan 2023 09:31:08 +0100 Subject: [PATCH 1/2] 6366: no pipeline fail when no data changes --- .gitlab-ci.yml | 7 ++----- build_list.js | 7 ++++++- doupdate.sh | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100755 doupdate.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b034dc5b..18ce9eee 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,8 +23,5 @@ build-list: - git config --global user.email "$GITLAB_USER_EMAIL" script: - - node build_list.js - - node validate_json.js - - git add list/e_trackers.json - - git commit -m "Auto update trackers list" - - git push origin HEAD:main + - doupdate.sh + diff --git a/build_list.js b/build_list.js index 6b986608..aa2dca26 100644 --- a/build_list.js +++ b/build_list.js @@ -8,6 +8,8 @@ const https = require('https') const fs = require('fs') const url = require('url') +const EXIT_CODE_NO_CHANGES = 5 + function fetch(url) { return new Promise((resolve, reject) => { https.get(url, (response) => { @@ -56,6 +58,7 @@ fetch(adawayUri) }) .then(toto => { if (listHasNoChanges()) { + process.exitCode = EXIT_CODE_NO_CHANGES throw "No changes in trackers, abort updating." } }) @@ -69,8 +72,10 @@ fetch(adawayUri) console.log("DONE") }) .catch(err => { + if (process.exitCode === undefined) { + process.exitCode = 1 + } console.log(err) - process.exit(1) }) diff --git a/doupdate.sh b/doupdate.sh new file mode 100755 index 00000000..a7501d67 --- /dev/null +++ b/doupdate.sh @@ -0,0 +1,22 @@ +#!/bin/sh + + +node build_list.js + +RETVAL=$? + +case "$RETVAL" in + "0") + node validate_json.js + git add list/e_trackers.json + git commit -m "Auto update trackers list" + git push origin HEAD:main + ;; + "5") + RETVAL=0 + ;; + *) + ;; +esac + +exit $RETVAL -- GitLab From d39acf00c6030a92388bf1fb4b0245c1535b00af Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Thu, 12 Jan 2023 08:49:46 +0100 Subject: [PATCH 2/2] fix indentation. --- doupdate.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/doupdate.sh b/doupdate.sh index a7501d67..213f8ca6 100755 --- a/doupdate.sh +++ b/doupdate.sh @@ -6,17 +6,17 @@ node build_list.js RETVAL=$? case "$RETVAL" in - "0") - node validate_json.js - git add list/e_trackers.json - git commit -m "Auto update trackers list" - git push origin HEAD:main - ;; + "0") + node validate_json.js + git add list/e_trackers.json + git commit -m "Auto update trackers list" + git push origin HEAD:main + ;; "5") - RETVAL=0 - ;; - *) - ;; + RETVAL=0 + ;; + *) + ;; esac exit $RETVAL -- GitLab