Skip to content

feat: add timeout plugin for Jenkins to Bitbucket Pipelines conversio…#6

Merged
volta2030 merged 3 commits into
mainfrom
develop
May 6, 2026
Merged

feat: add timeout plugin for Jenkins to Bitbucket Pipelines conversio…#6
volta2030 merged 3 commits into
mainfrom
develop

Conversation

@volta2030
Copy link
Copy Markdown
Owner

This pull request adds support for converting Jenkins pipeline timeouts to Bitbucket Pipelines step-level timeouts (max-time). Now, when a Jenkins timeout option is detected in a stage, the converter will emit the corresponding max-time property in the generated Bitbucket YAML. The implementation includes a new plugin, updates to the core conversion logic, and documentation for both Jenkins and Bitbucket timeout options.

Timeout Conversion Support:

  • Added a new timeoutPlugin in src/plugins/timeout.ts that detects Jenkins timeout options, parses their values and units, and provides a step timeout in minutes for Bitbucket Pipelines (max-time).
  • Updated the JenkinsPlugin interface in src/plugins/types.ts to include an optional getMaxTime method for plugins that can provide a step timeout.
  • Registered the new timeoutPlugin in the plugins list in src/plugins/index.ts. [1] [2]

Core Conversion Logic:

  • Enhanced the StepItem type in src/converter.ts to support an optional maxTime property, and updated the step-building logic to extract the minimum timeout from all applicable plugins. [1] [2]
  • Modified the YAML output logic in src/converter.ts to emit the max-time property for steps when a timeout is present. [1] [2]

Documentation and Testing:

  • Added comprehensive documentation for Jenkins timeout and Bitbucket Pipelines max-time options, including conversion rules and examples in docs/jenkins/timeout.txt and docs/bitbucket/max-time.txt. [1] [2]
  • Added a new test Jenkinsfile (tests/Jenkinsfile-example5) demonstrating the use of the timeout option.

Other:

  • Bumped the package version to 0.2.5 in package.json.

…n; update documentation and examples

Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for converting Jenkins declarative timeout(...) stage options into Bitbucket Pipelines step-level max-time (minutes), extending the plugin system and the YAML emitter to carry step timeout metadata end-to-end.

Changes:

  • Added a new timeout Jenkins plugin converter that detects/parses timeouts and returns a max-time value in minutes.
  • Extended the plugin interface and conversion pipeline to compute/store a per-step maxTime and emit max-time: in generated YAML.
  • Added documentation and a new example Jenkinsfile, and bumped the npm package version.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/Jenkinsfile-example5 New example Jenkinsfile demonstrating options { timeout(...) }.
src/plugins/types.ts Extends JenkinsPlugin with optional getMaxTime() hook.
src/plugins/timeout.ts New plugin implementing timeout detection and unit conversion.
src/plugins/index.ts Registers the new timeoutPlugin.
src/converter.ts Adds maxTime to step model, computes min timeout across plugins, emits max-time in YAML.
package.json Version bump to 0.2.5.
package-lock.json Lockfile version metadata updated to 0.2.5.
docs/jenkins/timeout.txt New Jenkins timeout documentation and conversion rules.
docs/bitbucket/max-time.txt New Bitbucket max-time documentation and mapping notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/plugins/timeout.ts Outdated
Comment thread src/plugins/timeout.ts
Comment on lines +41 to +46
const m = stageContent.match(
/\btimeout\s*\(\s*time\s*:\s*(\d+)\s*,\s*unit\s*:\s*['"](\w+)['"]\s*\)/
);
if (!m) return undefined;
const value = parseInt(m[1], 10);
const unit = m[2].toUpperCase();
Comment thread src/plugins/timeout.ts
Comment on lines +24 to +30
detect(content: string): boolean {
return /\btimeout\s*\(/.test(content);
},

detectInStage(stageContent: string): boolean {
return /options\s*\{[^}]*\btimeout\s*\(/s.test(stageContent);
},
Comment thread src/converter.ts
Comment on lines +319 to +331
// Collect the minimum timeout (in minutes) from all plugins that support it
let maxTime: number | undefined;
for (const plugin of plugins) {
if (plugin.getMaxTime) {
const t = plugin.getMaxTime(blockContent);
if (t !== undefined) {
maxTime = maxTime === undefined ? t : Math.min(maxTime, t);
}
}
}
if (maxTime !== undefined) logger.log(`Stage '${name}': timeout -> max-time: ${maxTime} minutes`);

return { kind: 'step', name, commands, activePlugins, postActions, maxTime };
Comment thread src/converter.ts
Comment on lines +563 to +565
if (step.maxTime !== undefined) {
lines.push(` max-time: ${step.maxTime}`);
}
Comment thread docs/jenkins/timeout.txt Outdated
volta2030 and others added 2 commits May 7, 2026 06:16
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@volta2030 volta2030 merged commit 998a24e into main May 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants