Change in osmo-ci[master]: jobs/redmine-fetch: close issues on gerrit merge

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

osmith gerrit-no-reply at lists.osmocom.org
Mon Nov 29 15:53:57 UTC 2021


osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/26423 )


Change subject: jobs/redmine-fetch: close issues on gerrit merge
......................................................................

jobs/redmine-fetch: close issues on gerrit merge

Add a job that is triggered by every gerrit merge, which translates the
GERRIT_PROJECT to the redmine project + repository and then triggers a
repository fetch by downloading the repository view url. Redmine will
then also parse the "Closes: OS#..." tags from commit messages and mark
related issues as resolved.

Redmine does not have a setting to fetch the repositories periodically
by itself, the redmine wiki recommends setting up a cron job or a
serverside git hook that also triggers the repository fetch. I have
considered implementing such a hook in gerrit instead, but then we would
not be able to see the logs as easily and notice failures.

Another consideration was fetching all redmine projects and associated
git repositories via redmine API and then just triggering a repository
fetch on all of them, in order to avoid the mapping from gerrit <>
redmine. However, the redmine API apparently doesn't list the
repositories and one would need to iterate through the projects,
recursively.

I have tested this job and verified that GERRIT_PROJECT gets set as
expected.

Related: https://www.redmine.org/projects/redmine/wiki/RedmineSettings#Fetch-commits-automatically
Related: OS#5331
Change-Id: Ia7c6c8426e5ca0de04378cedd0360c368e9d5027
---
A jobs/redmine-fetch.yml
1 file changed, 105 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/23/26423/1

diff --git a/jobs/redmine-fetch.yml b/jobs/redmine-fetch.yml
new file mode 100644
index 0000000..59903b3
--- /dev/null
+++ b/jobs/redmine-fetch.yml
@@ -0,0 +1,105 @@
+# Fetch repositories in redmine, in order to mark issues as resolved where
+# mentioned in commit messages (OS#5331).
+
+- job:
+    name: redmine-fetch
+    project-type: freestyle
+    node: osmocom-gerrit-debian9
+    properties:
+      - build-discarder:
+          days-to-keep: 30
+          num-to-keep: 120
+    description: |
+      Fetch repositories in redmine, in order to mark issues as resolved where
+      mentioned in commit messages.
+      </br></br>
+      Related issue: <a href="https://osmocom.org/issues/5331">OS#5331</a>
+    triggers:
+      - gerrit:
+          trigger-on:
+            - change-merged-event
+          projects:
+            - project-compare-type: 'ANT'
+              project-pattern: '**'
+              branches:
+                - branch-compare-type: 'ANT'
+                  branch-pattern: '**'
+    builders:
+      - shell: |-
+          # When triggered from gerrit, GERRIT_PROJECT is set. Use "osmo-bts"
+          # as dummy value for manual triggers.
+          if [ -z "$GERRIT_PROJECT" ]; then
+            GERRIT_PROJECT="erlang/mgw_nat"
+          fi
+
+          # Translate GERRIT_PROJECT name to redmine project name and
+          # repository. One redmine project can have multiple repositories.
+          PROJECT="$GERRIT_PROJECT"
+          REPO="$GERRIT_PROJECT"
+
+          case "$GERRIT_PROJECT" in
+            # Git repo not in redmine (multiple lines for readability)
+            asn1c|erlang/osmo_dia2gsup|erlang/osmo_gsup|titan.*|gr-gsm)
+              exit 0
+              ;;
+            gtp-load-gen|libasn1c|libgtpnl|libtelnet|libusrp|meta-telephony)
+              exit 0
+              ;;
+            mncc-python|openbsc|openggsn|openpcd|osmo-sdf4-dfu|osmo-dev)
+              exit 0
+              ;;
+            osmo-e2ltpd|osmo-el2tpd|osmo-gsm-manuals|osmo-gsm-tester|osmo-iuh)
+              exit 0
+              ;;
+            osmo-sysmon|osmo-upf|osmocom-lcs|python/osmo-python-tests|sandbox)
+              exit 0
+              ;;
+
+            # Git repo or project name not the same as gerrit project
+            docker-playground|osmo-ttcn3-hacks|osmo-ci)
+              PROJECT="core-testing-infra"
+              ;;
+            erlang/*)
+              PROJECT="$(echo "$GERRIT_PROJECT" | tr '/' '-')"
+              REPO="$PROJECT"
+              ;;
+            osmo-bsc)
+              PROJECT="osmobsc"
+              ;;
+            osmo-bts)
+              PROJECT="osmobts"
+              ;;
+            osmo-e1-hardware|osmo-e1d)
+              PROJECT="e1-t1-adapter"
+              ;;
+            osmo-ggsn)
+              PROJECT="openggsn"
+              ;;
+            osmo-msc)
+              PROJECT="osmomsc"
+              ;;
+            osmo-pcu)
+              PROJECT="osmopcu"
+              ;;
+            osmo-sgsn)
+              PROJECT="osmosgsn"
+              ;;
+            osmo-sip-connector)
+              PROJECT="osmo-sip-conector"
+              ;;
+            osmo-tetra)
+              PROJECT="tetra"
+              REPO="osmotetra"
+              ;;
+            osmo-trx)
+              PROJECT="osmotrx"
+              ;;
+            osmocom-bb)
+              PROJECT="baseband"
+              REPO="osmocombb"
+              ;;
+          esac
+
+          wget \
+            -O /dev/null \
+            "https://osmocom.org/projects/$PROJECT/repository/$REPO"

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/26423
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: Ia7c6c8426e5ca0de04378cedd0360c368e9d5027
Gerrit-Change-Number: 26423
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211129/8e0550d3/attachment.htm>


More information about the gerrit-log mailing list