From 446d20c23d6d90a1f36e9169b118759e36fc5d71 Mon Sep 17 00:00:00 2001 From: L3D Date: Wed, 10 May 2023 00:08:43 +0200 Subject: [PATCH] Create better error message for forgejo releases + Incremented simple version check + Added better error messages for chosing the wrong forgejo version SOLVE https://github.com/roles-ansible/ansible_role_gitea/issues/106 --- tasks/set_forgejo_version.yml | 20 +++++++++++++------- vars/main.yml | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tasks/set_forgejo_version.yml b/tasks/set_forgejo_version.yml index f44218f..7b3d195 100644 --- a/tasks/set_forgejo_version.yml +++ b/tasks/set_forgejo_version.yml @@ -35,18 +35,24 @@ gitea_version_target: "{{ gitea_remote_version }}" when: not ansible_check_mode -- name: "Set gitea version target {{ gitea_version }}" +- name: "Set forgejo version target {{ gitea_version }}" ansible.builtin.set_fact: gitea_version_target: "{{ gitea_version }}" when: gitea_version != "latest" -- name: "Get specific forgejo release metadata" - ansible.builtin.uri: - url: 'https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/tags/v{{ gitea_version_target }}' - return_content: true - register: gitea_forgejo_remote_tags_metadata - become: false +- name: "Download forgejo version {{ gitea_version_target }}" when: not ansible_check_mode + block: + - name: "Get specific forgejo release metadata" + ansible.builtin.uri: + url: 'https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/tags/v{{ gitea_version_target }}' + return_content: true + register: gitea_forgejo_remote_tags_metadata + become: false + rescue: + - name: "Error Downloading https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/tags/v{{ gitea_version_target }}" + ansible.builtin.fail: + msg: "We did not find the forgejo version you specified. Are you sure that '{{ gitea_version_target }}' is a valid forgejo version?" - name: "Generate forgejo download url" ansible.builtin.set_fact: diff --git a/vars/main.yml b/vars/main.yml index f14adbd..b9a43e6 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -62,5 +62,5 @@ transfer_custom_footer: - 'files/gitea_footer/extra_links_footer.tmpl' - 'files/extra_links_footer.tmpl' -playbook_version_number: 45 # should be int +playbook_version_number: 46 # should be int playbook_version_path: 'do1jlr.gitea.version'