Add option for setting timeout of exec command

parent 0fea0adc
Pipeline #2437007 passed with stage
v 1.2.0 (unreleased)
- Add `timeout` option for the `exec` command
v 1.1.0
- Use Go 1.5
......@@ -23,7 +24,7 @@ v 1.1.0
- Fix: Don't restore cache if not defined in gitlab-ci.yml
- Fix: Always use `json-file` when starting docker containers
- Fix: Error level checking for Windows Batch and PowerShell
v 1.0.4
- Fix support for Windows PowerShell
......
......@@ -23,7 +23,8 @@ import (
type ExecCommand struct {
common.RunnerSettings
Job string
Job string
Timeout int `long:"timeout" description:"Job execution timeout"`
}
func (c *ExecCommand) runCommand(name string, arg ...string) (string, error) {
......@@ -203,7 +204,7 @@ func (c *ExecCommand) createBuild(repoURL string, abortSignal chan os.Signal) (b
RefName: strings.TrimSpace(refName),
BeforeSha: strings.TrimSpace(beforeSha),
AllowGitFetch: false,
Timeout: 30 * 60,
Timeout: c.getTimeout(),
Token: "",
Name: "",
Stage: "",
......@@ -217,6 +218,14 @@ func (c *ExecCommand) createBuild(repoURL string, abortSignal chan os.Signal) (b
return
}
func (c *ExecCommand) getTimeout() int {
if c.Timeout > 0 {
return c.Timeout
}
return common.DefaultExecTimeout
}
func (c *ExecCommand) Execute(context *cli.Context) {
wd, err := os.Getwd()
if err != nil {
......
......@@ -3,6 +3,7 @@ package common
import "time"
const DefaultTimeout = 7200
const DefaultExecTimeout = 1800
const CheckInterval = 3
const NotHealthyCheckInterval = 300
const UpdateInterval = 3 * time.Second
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment