Skip to content

Develop#4

Merged
volta2030 merged 3 commits into
mainfrom
develop
Apr 23, 2026
Merged

Develop#4
volta2030 merged 3 commits into
mainfrom
develop

Conversation

@volta2030
Copy link
Copy Markdown
Owner

This pull request introduces support for Jenkins pipeline stages that use the parallel block, enabling conversion of Jenkinsfiles with parallel test or build stages into the correct Bitbucket Pipelines YAML structure. It also refactors the internal representation of stages to distinguish between regular steps and parallel groups, and adds a new test case to verify the feature.

Key changes:

Parallel stage support and pipeline structure:

  • Refactored the internal representation of pipeline stages by introducing StepItem, ParallelItem, and a union type PipelineItem, allowing the converter to distinguish between regular and parallel stages. The YAML output now correctly emits parallel blocks for Bitbucket Pipelines when parallel stages are detected in the Jenkinsfile. [1] [2] [3]
  • Added a helper function findDirectChildStages to accurately extract direct child stages from both regular and parallel blocks, ensuring correct parsing and nesting.
  • Implemented an emitStepScript helper to centralize and unify the logic for emitting script lines for each step, reducing code duplication and improving maintainability.

Testing and documentation:

  • Added a new test Jenkinsfile (tests/Jenkinsfile-example3) that includes both regular and parallel stages to verify the new parallel conversion logic.
  • Updated the package.json version to 0.2.3 and added a DeepWiki badge to the README.md for improved documentation and discoverability. [1] [2]

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

Adds conversion support for Jenkins Declarative Pipeline parallel { ... } stages, emitting the corresponding Bitbucket Pipelines parallel: YAML structure while refactoring stage representation to distinguish single steps vs parallel groups.

Changes:

  • Introduces StepItem / ParallelItem and parses direct child stages to detect parallel {} blocks.
  • Updates YAML emission to output Bitbucket parallel: blocks and refactors script emission via emitStepScript.
  • Adds a new Jenkinsfile fixture for parallel-stage scenarios and bumps package version/docs badge.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/Jenkinsfile-example3 Adds a Jenkinsfile fixture containing both regular stages and a parallel stage group.
src/converter.ts Refactors stage parsing and YAML emission to support parallel blocks; adds helper utilities.
package.json Bumps package version to 0.2.3.
package-lock.json Updates lockfile version fields to 0.2.3.
README.md Adds a DeepWiki badge.

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

Comment thread src/converter.ts Outdated
Comment thread src/converter.ts
Comment on lines +210 to +219

for (const m of body.matchAll(pattern)) {
// Count brace depth at this match position
let depth = 0;
for (let i = 0; i < m.index!; i++) {
if (body[i] === '{') depth++;
else if (body[i] === '}') depth--;
}
if (depth === 0) {
const block = getBalancedBlock(body, m.index!);
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

findDirectChildStages computes brace depth by scanning from the start of body up to each regex match index, which makes this O(n*m) for n=body length and m=number of stage(...) matches. On larger Jenkinsfiles (or ones with many nested blocks), this can become a noticeable bottleneck. Consider a single-pass scan that tracks current brace depth while searching for stage(...), or precompute a depth-at-index array once per body string.

Suggested change
for (const m of body.matchAll(pattern)) {
// Count brace depth at this match position
let depth = 0;
for (let i = 0; i < m.index!; i++) {
if (body[i] === '{') depth++;
else if (body[i] === '}') depth--;
}
if (depth === 0) {
const block = getBalancedBlock(body, m.index!);
let depth = 0;
let lastScannedIndex = 0;
let m: RegExpExecArray | null;
while ((m = pattern.exec(body)) !== null) {
const matchIndex = m.index;
// Update brace depth only for the characters since the previous match.
for (let i = lastScannedIndex; i < matchIndex; i++) {
if (body[i] === '{') depth++;
else if (body[i] === '}') depth--;
}
lastScannedIndex = matchIndex;
if (depth === 0) {
const block = getBalancedBlock(body, matchIndex);

Copilot uses AI. Check for mistakes.
Comment thread src/converter.ts
Comment on lines +427 to +440
for (const item of items) {
if (item.kind === 'parallel') {
lines.push(' - parallel:');
for (const step of item.steps) {
lines.push(' - step:');
lines.push(` name: ${step.name}`);
if (runners) {
lines.push(' runs-on:');
for (const r of runners) lines.push(` - ${r}`);
}
lines.push(' script:');
emitStepScript(step, ' ');
}
lines.push('');
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

Parallel-stage conversion is introduced here, but the automated test suite doesn’t appear to assert the emitted parallel: YAML structure (and tests/Jenkinsfile-example3 isn’t referenced by the current Jest tests). Add/extend a unit test that converts a Jenkinsfile containing a parallel { stage(...) ... } block and asserts the resulting YAML has a parallel item with the expected sub-steps.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,41 @@

Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

This fixture file starts with a blank line, so the shebang (#!/usr/bin/env groovy) is not on the first line. If the file is ever executed directly, the shebang will be ignored. Consider removing the leading blank line so the shebang is line 1.

Suggested change

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@volta2030 volta2030 merged commit 57aac6e into main Apr 23, 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