report flavor in build's description

This commit is contained in:
Quentin 2023-03-16 16:31:08 +01:00
parent 28f44e5778
commit 6bb4ecc9f7
Signed by: quentin
GPG Key ID: E9602264D639FF68
1 changed files with 5 additions and 3 deletions

View File

@ -113,7 +113,7 @@ func notifSummary(notification *GiteaNotification) string {
return fmt.Sprintf("%s/%s:%s", notification.Repository.Owner.Username, notification.Repository.Name, notification.After)
}
func lifecycle(notification *GiteaNotification, dispatch *nomad.JobDispatchResponse, giteaCreds *SecretGitea) {
func lifecycle(notification *GiteaNotification, dispatch *nomad.JobDispatchResponse, giteaCreds *SecretGitea, flavor string) {
notifInfo := notifSummary(notification)
log.Printf("[lifecycle] Commit to build: %s, Gitea URL: %s\n", notifInfo, giteaCreds.Url)
@ -158,7 +158,7 @@ func lifecycle(notification *GiteaNotification, dispatch *nomad.JobDispatchRespo
gitea.CreateStatusOption{
State: state,
TargetURL: GlobalConfig.AlbatrosURL + "/build?log=stderr&job=" + dispatch.DispatchedJobID,
Description: "build",
Description: flavor,
Context: "Albatros",
})
@ -213,6 +213,7 @@ func hook(w http.ResponseWriter, r *http.Request) {
pair, _, err := kv.Get(key, nil)
if err != nil {
http.Error(w, "Can't fetch the repo descriptor in Consul", http.StatusInternalServerError)
log.Printf("Job error for %s, can't fetch repo descriptor in consul: %+v\n", notifInfo, err)
return
}
if pair == nil || pair.Value == nil {
@ -223,6 +224,7 @@ func hook(w http.ResponseWriter, r *http.Request) {
var repoDesc ConsulSecret
if err = json.Unmarshal(pair.Value, &repoDesc); err != nil {
http.Error(w, "Can't decode your Consul configuration for this repo", http.StatusInternalServerError)
log.Printf("Job error for %s, can't unmarshal the Consul descriptor: %+v\n", notifInfo, err)
return
}
// Check token
@ -256,7 +258,7 @@ func hook(w http.ResponseWriter, r *http.Request) {
log.Printf("Created job %s for %s\n", dres.DispatchedJobID, notifInfo)
// Start a lifecycle observer to update gitea status
go lifecycle(&notification, dres, &repoDesc.Gitea)
go lifecycle(&notification, dres, &repoDesc.Gitea, flavor)
io.WriteString(w, dres.DispatchedJobID)
}