mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
Using configured server URL instead of obtained from request (#175)
Woodpecker should use configured server URL when creating self URL-s for VCS UI and not depend on URL read from request. In case of internal calls like answers for webhooks from Gitea on backend, address in URL may be internal and this causes Gitea to display CI status for commit with intenal URL to woodpecker not external one.
This commit is contained in:
parent
d40a4a4b32
commit
68dbd488a9
4 changed files with 17 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
|||
// Copyright 2018 Drone.IO Inc.
|
||||
// Copyright 2021 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -11,6 +12,8 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// This file has been modified by Informatyka Boguslawski sp. z o.o. sp.k.
|
||||
|
||||
package server
|
||||
|
||||
|
@ -21,7 +24,6 @@ import (
|
|||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/model"
|
||||
"github.com/woodpecker-ci/woodpecker/shared/httputil"
|
||||
"github.com/woodpecker-ci/woodpecker/store"
|
||||
)
|
||||
|
||||
|
@ -92,7 +94,7 @@ func GetCC(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s/%d", httputil.GetURL(c.Request), repo.FullName, builds[0].Number)
|
||||
url := fmt.Sprintf("%s/%s/%d", Config.Server.Host, repo.FullName, builds[0].Number)
|
||||
cc := model.NewCC(repo, builds[0], url)
|
||||
c.XML(200, cc)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright 2018 Drone.IO Inc.
|
||||
// Copyright 2021 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -11,6 +12,8 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// This file has been modified by Informatyka Boguslawski sp. z o.o. sp.k.
|
||||
|
||||
package server
|
||||
|
||||
|
@ -326,7 +329,7 @@ func PostApproval(c *gin.Context) {
|
|||
|
||||
defer func() {
|
||||
for _, item := range buildItems {
|
||||
uri := fmt.Sprintf("%s/%s/%d", httputil.GetURL(c.Request), repo.FullName, build.Number)
|
||||
uri := fmt.Sprintf("%s/%s/%d", Config.Server.Host, repo.FullName, build.Number)
|
||||
if len(buildItems) > 1 {
|
||||
err = remote_.Status(user, repo, build, uri, item.Proc)
|
||||
} else {
|
||||
|
@ -367,7 +370,7 @@ func PostDecline(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
uri := fmt.Sprintf("%s/%s/%d", httputil.GetURL(c.Request), repo.FullName, build.Number)
|
||||
uri := fmt.Sprintf("%s/%s/%d", Config.Server.Host, repo.FullName, build.Number)
|
||||
err = remote_.Status(user, repo, build, uri, nil)
|
||||
if err != nil {
|
||||
logrus.Errorf("error setting commit status for %s/%d: %v", repo.FullName, build.Number, err)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright 2018 Drone.IO Inc.
|
||||
// Copyright 2021 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -11,6 +12,8 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// This file has been modified by Informatyka Boguslawski sp. z o.o. sp.k.
|
||||
|
||||
package server
|
||||
|
||||
|
@ -273,7 +276,7 @@ func PostHook(c *gin.Context) {
|
|||
|
||||
defer func() {
|
||||
for _, item := range buildItems {
|
||||
uri := fmt.Sprintf("%s/%s/%d", httputil.GetURL(c.Request), repo.FullName, build.Number)
|
||||
uri := fmt.Sprintf("%s/%s/%d", Config.Server.Host, repo.FullName, build.Number)
|
||||
if len(buildItems) > 1 {
|
||||
err = remote_.Status(user, repo, build, uri, item.Proc)
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Copyright 2018 Drone.IO Inc.
|
||||
// Copyright 2021 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -11,6 +12,8 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// This file has been modified by Informatyka Boguslawski sp. z o.o. sp.k.
|
||||
|
||||
package server
|
||||
|
||||
|
@ -465,7 +468,7 @@ func (s *RPC) updateRemoteStatus(repo *model.Repo, build *model.Build, proc *mod
|
|||
s.store.UpdateUser(user)
|
||||
}
|
||||
}
|
||||
uri := fmt.Sprintf("%s/%s/%d", s.host, repo.FullName, build.Number)
|
||||
uri := fmt.Sprintf("%s/%s/%d", Config.Server.Host, repo.FullName, build.Number)
|
||||
err = s.remote.Status(user, repo, build, uri, proc)
|
||||
if err != nil {
|
||||
logrus.Errorf("error setting commit status for %s/%d: %v", repo.FullName, build.Number, err)
|
||||
|
|
Loading…
Reference in a new issue