Make gitea public URL configurable

Otherwise, it will be obtained from the jobset input that contains the
URL to the git repo to build.
This commit is contained in:
Maximilian Bosch 2021-03-30 23:01:36 +02:00
parent eecea56131
commit f9f5ab2fb1
No known key found for this signature in database
GPG key ID: 091DBF4D1FC46B8E
3 changed files with 17 additions and 7 deletions

View file

@ -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 |

View file

@ -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

View file

@ -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);