Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gitea release handling #60

Merged
merged 17 commits into from
Jan 29, 2024

Conversation

Mai-Lapyst
Copy link
Contributor

@Mai-Lapyst Mai-Lapyst commented Aug 16, 2022

This PR adds the ability to discover releases in gitea as "branches" to be build seperatly.

It also adds an task for pipelines ("publishGiteaAssets") which works a little like copyArtifacts but uploads artifacts as an asset to the current building release.

The PR also contains an (toggleable) feature to "map" artifacts originally created via copyArtifacts to gitea release assets.

Relevant issues:


  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@lafriks
Copy link
Contributor

lafriks commented Aug 16, 2022

Please fix lint errors

@Mai-Lapyst
Copy link
Contributor Author

Please fix lint errors

Should be fixed now

pom.xml Outdated Show resolved Hide resolved
@lafriks
Copy link
Contributor

lafriks commented Oct 12, 2022

Is this still a WIP or finished? (asking because there is quite some TODO left in code)

@Mai-Lapyst
Copy link
Contributor Author

Is this still a WIP or finished? (asking because there is quite some TODO left in code)

It's finished. I left the TODO's mostly there to note things for future additions or to match the rest of the file (in case of MockGiteaConnection).

@lafriks
Copy link
Contributor

lafriks commented Oct 31, 2022

I would say draft releases should be skipped and removed from this as in the future it's planned that gitea won't issue webhooks for draft releases (go-gitea/gitea#21594)

@Mai-Lapyst
Copy link
Contributor Author

I would say draft releases should be skipped and removed from this as in the future it's planned that gitea won't issue webhooks for draft releases (go-gitea/gitea#21594)

Yeah makes sense; will update the PR in the coming days.

@RokkuCode
Copy link

any news on this when it will merged? this change would help us in handling releases with gitea.

@RokkuCode
Copy link

@lafriks are there blockers why this pr is not merged yet?

@Mai-Lapyst
Copy link
Contributor Author

Rebased pr to current master

@justusbunsi
Copy link
Member

@Mai-Lapyst @lafriks As mentioned in #67, my apologies for not responding earlier. I received the "review requested" notification back then and simply missed acting upon it after reading it. Reviewing and testing your changes now.

Copy link
Member

@justusbunsi justusbunsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mai-Lapyst Thank you for this great contribution.

It looks like the current implementation does not fully take the "prerelease" flag into account. Instead, scanning the repository triggers all releases anyway. I've suggested changes to fixes that behavior.

And there is something off with publishGiteaAssets. I am not sure what exactly. Do you have an idea?

@Mai-Lapyst
Copy link
Contributor Author

Added a additional patch since the generation of the url for fetching releases was still not correct; but this time bc gitea interprets draft=true as a way to ONLY include drafts in the response. Should be fixed now by only specifing draft=false when no drafts should be fetched. Same goes for the pre-release flag.

@AdamRGrey
Copy link

@justusbunsi not to annoy, but plz pretty plz

(i'm looking forward to this feature)

@justusbunsi
Copy link
Member

@justusbunsi not to annoy, but plz pretty plz

(i'm looking forward to this feature)

I'll review until the end of week. My daily schedule did not allow rewiewing earlier. Should've commented earlier. 🙂

Copy link
Member

@justusbunsi justusbunsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mai-Lapyst, thanks for the deep dive regarding asset uploads from local machine. It is working for me now, too. 👍

I've noticed one last detail that should be added in this PR: Commit status informing about the build state of a release - like it's done for tags. It requires a change in GiteaNotifier.java which is unchanged and I don't know how to suggest the changes in unchanged files via GitHub UI. So here are my suggestions for this missing part. As soon as release builds send their status to Gitea: This PR is going to LGTM 😃

diff --git a/src/main/java/org/jenkinsci/plugin/gitea/GiteaNotifier.java b/src/main/java/org/jenkinsci/plugin/gitea/GiteaNotifier.java
index 23ee4a3..eb45482 100644
--- a/src/main/java/org/jenkinsci/plugin/gitea/GiteaNotifier.java
+++ b/src/main/java/org/jenkinsci/plugin/gitea/GiteaNotifier.java
@@ -132,6 +132,11 @@ public class GiteaNotifier {
                     status.getState().name(), status.getDescription());
             hash = ((TagSCMRevision) revision).getHash();
             statusContext += "tag";
+        } else if (revision instanceof ReleaseSCMRevision) {
+            listener.getLogger().format("[Gitea] Notifying release build status: %s %s%n",
+                    status.getState().name(), status.getDescription());
+            hash = ((ReleaseSCMRevision) revision).getHash();
+            statusContext += "release";
         } else {
             return;
         }
@@ -237,6 +242,10 @@ public class GiteaNotifier {
                             LOGGER.log(Level.INFO, "Notifying tag pending build {0}", job.getFullName());
                             statusContext += "tag";
                             hash = ((TagSCMRevision) revision).getHash();
+                        } else if (revision instanceof ReleaseSCMRevision) {
+                            LOGGER.log(Level.INFO, "Notifying release pending build {0}", job.getFullName());
+                            statusContext += "release";
+                            hash = ((ReleaseSCMRevision) revision).getHash();
                         } else {
                             return;
                         }

@Mai-Lapyst
Copy link
Contributor Author

@justusbunsi Have added the requested changes; should work now :)

Copy link
Member

@justusbunsi justusbunsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@justusbunsi justusbunsi merged commit 2d81242 into jenkinsci:master Jan 29, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants