contacts agent to cancel build
This commit is contained in:
parent
3863617056
commit
543a46a755
2 changed files with 21 additions and 2 deletions
|
@ -1,7 +1,10 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -239,5 +242,21 @@ func KillBuild(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the agent from the repository so we can
|
||||||
|
// notify the agent to kill the build.
|
||||||
|
agent, err := store.BuildAgent(repo.FullName, build.Number)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(200, build)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
url_, _ := url.Parse("http://" + agent.Addr)
|
||||||
|
url_.Path = fmt.Sprintf("/cancel/%s/%v", repo.FullName, build.Number)
|
||||||
|
resp, err := http.Post(url_.String(), "application/json", nil)
|
||||||
|
if err != nil {
|
||||||
|
c.Fail(500, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
c.JSON(200, build)
|
c.JSON(200, build)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
<a href="/{{ repo.full_name }}">Back</a>
|
<a href="/{{ repo.full_name }}">Back</a>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button ng-if="build.state !== 'pending' && build.state !== 'started'" ng-click="restart()">Restart</button>
|
<button ng-if="build.state !== 'pending' && build.state !== 'running'" ng-click="restart()">Restart</button>
|
||||||
<button ng-if="build.state === 'pending' || build.state === 'started'" ng-click="cancel()">Cancel</button>
|
<button ng-if="build.state === 'pending' || build.state === 'running'" ng-click="cancel()">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
|
|
Loading…
Reference in a new issue