From f9f5ab2fb1720be2ab1ffa741a4a01020e93d30a Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Tue, 30 Mar 2021 23:01:36 +0200 Subject: [PATCH] Make gitea public URL configurable Otherwise, it will be obtained from the jobset input that contains the URL to the git repo to build. --- doc/manual/src/projects.md | 11 ++++++----- flake.nix | 3 ++- src/lib/Hydra/Plugin/GiteaStatus.pm | 10 +++++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/doc/manual/src/projects.md b/doc/manual/src/projects.md index 3b9b8eb1..3c1d7017 100644 --- a/doc/manual/src/projects.md +++ b/doc/manual/src/projects.md @@ -486,9 +486,10 @@ analogous: * For a jobset with a `Git`-input which points to a `gitea`-instance, add the following additional inputs: - | Type | Name | Value | - | -------------- | ------------------- | ----------------------------------- | - | `String value` | `gitea_repo_name` | *Name of the repository to build* | - | `String value` | `gitea_repo_owner` | *Owner of the repository* | - | `String value` | `gitea_status_repo` | *Name of the `Git checkout` input* | + | Type | Name | Value | + | -------------- | ------------------- | ---------------------------------- | + | `String value` | `gitea_repo_name` | *Name of the repository to build* | + | `String value` | `gitea_repo_owner` | *Owner of the repository* | + | `String value` | `gitea_status_repo` | *Name of the `Git checkout` input* | + | `String value` | `gitea_http_url` | *Public URL of `gitea`*, optional | diff --git a/flake.nix b/flake.nix index b61f7602..67d318ad 100644 --- a/flake.nix +++ b/flake.nix @@ -591,7 +591,8 @@ "git": {"value": "http://localhost:3001/root/repo.git", "type": "git"}, "gitea_repo_name": {"value": "repo", "type": "string"}, "gitea_repo_owner": {"value": "root", "type": "string"}, - "gitea_status_repo": {"value": "git", "type": "string"} + "gitea_status_repo": {"value": "git", "type": "string"}, + "gitea_http_url": {"value": "http://localhost:3001", "type": "string"} } } EOF diff --git a/src/lib/Hydra/Plugin/GiteaStatus.pm b/src/lib/Hydra/Plugin/GiteaStatus.pm index 9c67c2a5..b8da1d0f 100644 --- a/src/lib/Hydra/Plugin/GiteaStatus.pm +++ b/src/lib/Hydra/Plugin/GiteaStatus.pm @@ -55,6 +55,7 @@ sub common { next unless defined $giteastatusInput && defined $giteastatusInput->value; my $i = $eval->jobsetevalinputs->find({ name => $giteastatusInput->value, altnr => 0 }); next unless defined $i; + my $gitea_url = $eval->jobsetevalinputs->find({ name => "gitea_http_url" }); my $repoOwner = $eval->jobsetevalinputs->find({ name => "gitea_repo_owner" })->value; my $repoName = $eval->jobsetevalinputs->find({ name => "gitea_repo_name" })->value; @@ -62,7 +63,14 @@ sub common { my $rev = $i->revision; my $domain = URI->new($i->uri)->host; - my $url = "http://$domain:3001/api/v1/repos/$repoOwner/$repoName/statuses/$rev"; + my $host; + unless (defined $gitea_url) { + $host = "https://$domain"; + } else { + $host = $gitea_url->value; + } + + my $url = "$host/api/v1/repos/$repoOwner/$repoName/statuses/$rev"; print STDERR "GiteaStatus POSTing $state to $url\n"; my $req = HTTP::Request->new('POST', $url);