Conversation
…n; update documentation and examples Co-authored-by: Copilot <copilot@github.com>
Contributor
There was a problem hiding this comment.
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
timeoutJenkins plugin converter that detects/parses timeouts and returns amax-timevalue in minutes. - Extended the plugin interface and conversion pipeline to compute/store a per-step
maxTimeand emitmax-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 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 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 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 on lines
+563
to
+565
| if (step.maxTime !== undefined) { | ||
| lines.push(` max-time: ${step.maxTime}`); | ||
| } |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for converting Jenkins pipeline timeouts to Bitbucket Pipelines step-level timeouts (
max-time). Now, when a Jenkinstimeoutoption is detected in a stage, the converter will emit the correspondingmax-timeproperty 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:
timeoutPlugininsrc/plugins/timeout.tsthat detects Jenkinstimeoutoptions, parses their values and units, and provides a step timeout in minutes for Bitbucket Pipelines (max-time).JenkinsPlugininterface insrc/plugins/types.tsto include an optionalgetMaxTimemethod for plugins that can provide a step timeout.timeoutPluginin the plugins list insrc/plugins/index.ts. [1] [2]Core Conversion Logic:
StepItemtype insrc/converter.tsto support an optionalmaxTimeproperty, and updated the step-building logic to extract the minimum timeout from all applicable plugins. [1] [2]src/converter.tsto emit themax-timeproperty for steps when a timeout is present. [1] [2]Documentation and Testing:
timeoutand Bitbucket Pipelinesmax-timeoptions, including conversion rules and examples indocs/jenkins/timeout.txtanddocs/bitbucket/max-time.txt. [1] [2]tests/Jenkinsfile-example5) demonstrating the use of thetimeoutoption.Other:
0.2.5inpackage.json.