diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index 362f3af83f65fd8f2157d624c4d9df64953432e7..6283d86b00310a85ee96fa011b792eee3dc385e3 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -250,6 +250,11 @@ e.g. ## endpoint +## executionTimeout + +Default execution timeout in minutes for child processes Renovate creates. +If this option is not set, Renovate will fallback to 15 minutes. + ## exposeAllEnv By default, Renovate only passes a limited set of environment variables to package managers. diff --git a/lib/config/global.ts b/lib/config/global.ts index 313bc2ff4bb32ca16ebab8244574dab70638ab9c..9a1b68f7fa1589272c3c9a77a19c8f05cde24b6b 100644 --- a/lib/config/global.ts +++ b/lib/config/global.ts @@ -16,6 +16,7 @@ export class GlobalConfig { 'dockerUser', 'dryRun', 'exposeAllEnv', + 'executionTimeout', 'localDir', 'migratePresets', 'privateKey', diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index 2d0d0bebb3aaf146675cd44de4a1286a1920bfa1..da9e1d713bbeba3713fdefa5a9514e3b9fe19cce 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -747,6 +747,14 @@ const options: RenovateOptions[] = [ subType: 'string', default: [], }, + { + name: 'executionTimeout', + description: + 'Default execution timeout in minutes for child processes Renovate creates.', + type: 'integer', + default: 15, + globalOnly: true, + }, { name: 'aliases', description: 'Aliases for registries, package manager specific.', diff --git a/lib/config/types.ts b/lib/config/types.ts index c1ca573ce60c5e73065515452044b1b6abc047f4..27634a140a6cf2d89ebd9d0d23942460e26f44cd 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -102,6 +102,7 @@ export interface RepoGlobalConfig { dockerImagePrefix?: string; dockerUser?: string; dryRun?: boolean; + executionTimeout?: number; exposeAllEnv?: boolean; migratePresets?: Record<string, string>; privateKey?: string; diff --git a/lib/util/exec/index.spec.ts b/lib/util/exec/index.spec.ts index eca56e89d98ebad942cd937f3a5eff2c9330a1c2..cf0eddd08589abb5b3e141d573644beb1407be3c 100644 --- a/lib/util/exec/index.spec.ts +++ b/lib/util/exec/index.spec.ts @@ -542,6 +542,26 @@ describe('util/exec/index', () => { }, ], + [ + 'Default timeout from executionTimeout config option', + { + processEnv, + inCmd, + inOpts: {}, + outCmd, + outOpts: [ + { + cwd, + encoding, + env: envMock.basic, + timeout: 30 * 60 * 1000, + maxBuffer: 10485760, + }, + ], + adminConfig: { executionTimeout: 30 }, + }, + ], + [ 'Explicit maxBuffer', { diff --git a/lib/util/exec/index.ts b/lib/util/exec/index.ts index 221790b16a6d7698543dd610bc49698fb75cfdcc..4e2310bf73a0f156a35892487cdd36b7961feecd 100644 --- a/lib/util/exec/index.ts +++ b/lib/util/exec/index.ts @@ -68,6 +68,7 @@ function getCwd({ cwd, cwdFile }: ExecOptions): string { } function getRawExecOptions(opts: ExecOptions): RawExecOptions { + const defaultExecutionTimeout = GlobalConfig.get('executionTimeout'); const execOptions: ExecOptions = { ...opts }; delete execOptions.extraEnv; delete execOptions.docker; @@ -82,8 +83,15 @@ function getRawExecOptions(opts: ExecOptions): RawExecOptions { env: childEnv, cwd, }; - // Set default timeout to 15 minutes - rawExecOptions.timeout = rawExecOptions.timeout || 15 * 60 * 1000; + // Set default timeout config.executionTimeout if specified; othrwise to 15 minutes + if (!rawExecOptions.timeout) { + if (defaultExecutionTimeout) { + rawExecOptions.timeout = defaultExecutionTimeout * 60 * 1000; + } else { + rawExecOptions.timeout = 15 * 60 * 1000; + } + } + // Set default max buffer size to 10MB rawExecOptions.maxBuffer = rawExecOptions.maxBuffer || 10 * 1024 * 1024; return rawExecOptions;