mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
ability to fork-exec and existing build
This commit is contained in:
parent
6566d55614
commit
0e5ee44700
1 changed files with 19 additions and 1 deletions
|
@ -147,6 +147,7 @@ func PostBuild(c *gin.Context) {
|
|||
|
||||
remote_ := remote.FromContext(c)
|
||||
repo := session.Repo(c)
|
||||
fork := c.DefaultQuery("fork", "false")
|
||||
|
||||
num, err := strconv.Atoi(c.Param("number"))
|
||||
if err != nil {
|
||||
|
@ -203,10 +204,26 @@ func PostBuild(c *gin.Context) {
|
|||
|
||||
// must not restart a running build
|
||||
if build.Status == model.StatusPending || build.Status == model.StatusRunning {
|
||||
c.AbortWithStatus(409)
|
||||
c.String(409, "Cannot re-start a started build")
|
||||
return
|
||||
}
|
||||
|
||||
// forking the build creates a duplicate of the build
|
||||
// and then executes. This retains prior build history.
|
||||
if forkit, _ := strconv.ParseBool(fork); forkit {
|
||||
build.ID = 0
|
||||
build.Number = 0
|
||||
for _, job := range jobs {
|
||||
job.ID = 0
|
||||
job.NodeID = 0
|
||||
}
|
||||
err := store.CreateBuild(c, build, jobs...)
|
||||
if err != nil {
|
||||
c.String(500, err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// todo move this to database tier
|
||||
// and wrap inside a transaction
|
||||
build.Status = model.StatusPending
|
||||
|
@ -218,6 +235,7 @@ func PostBuild(c *gin.Context) {
|
|||
job.Started = 0
|
||||
job.Finished = 0
|
||||
job.ExitCode = 0
|
||||
job.NodeID = 0
|
||||
job.Enqueued = build.Enqueued
|
||||
store.UpdateJob(c, job)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue