Skip to content

refactor: cross-platform build script compatibility (CUT-5128)#741

Open
junioralmeida-82 wants to merge 14 commits into
masterfrom
feature/CUT-5128-build-script-compatibility
Open

refactor: cross-platform build script compatibility (CUT-5128)#741
junioralmeida-82 wants to merge 14 commits into
masterfrom
feature/CUT-5128-build-script-compatibility

Conversation

@junioralmeida-82
Copy link
Copy Markdown
Contributor

@junioralmeida-82 junioralmeida-82 commented May 14, 2026

Description
Refactored the PowerShell build system in the support repository to ensure full cross-platform compatibility (macOS, Linux, and Windows).

Issues
CUT-5128 - Refactor build scripts for cross-platform support.

What does this solve?
Replaces manual path concatenations with Join-Path to handle different path separators (/ vs ) automatically.

Standardizes variable initialization when dot-sourcing Get-Config.ps1 to prevent "Null Argument" errors on non-Windows environments.

Modernizes the build orchestrator for better stability across different PowerShell versions (5.1 and 7+).

Is there anything particularly tricky?
Safety Bypass: As discussed with @joeworkman, the git push command in Invoke-GitCommit.ps1 has been commented out to prevent accidental commits during the build process until a separate deploy card is addressed.

How should this be tested?
Run the build script from the root of the repository:
pwsh ./PowerShell/Deploy/Build-Module.ps1 -ReleaseType Patch

Verify that all paths in the terminal logs resolve correctly according to the Host OS.

Check if the module manifest (.psd1) and ModuleChangelog.md are updated correctly.

Screenshots
Captura de Tela 2026-05-14 às 16 05 43

Captura de Tela 2026-05-14 às 16 06 03 Captura de Tela 2026-05-14 às 16 07 05

Note

Medium Risk
Medium risk because it changes the build/deploy orchestration and path resolution logic, which can break CI packaging if any derived paths or invoked scripts differ across platforms; also disables automated git commit/push, affecting release automation behavior.

Overview
Cross-platform build refactor: Build-Module.ps1 and Get-Config.ps1 now use Join-Path and explicit parameter passing when dot-sourcing config to avoid null/incorrect path issues on macOS/Linux.

Build orchestration changes: Build-Module.ps1 now optionally runs SDK sync (SdkSync/jcapiToSupportSync.ps1), generates help via Build-HelpFiles.ps1 (with temporary Set-Location to Docs), and autogenerates Pester tests, with Test-Path checks + warnings when scripts are missing.

Release/process updates: Invoke-GitCommit.ps1 comments out the git commit and git push steps to prevent accidental pushes during testing; adds PowerShell/Deploy/README.md; updates module/help artifacts and changelog for version 3.1.1 (manifest, JumpCloud.md, and new ModuleChangelog.md entry).

Reviewed by Cursor Bugbot for commit 07d64af. Bugbot is set up for automated code reviews on this repo. Configure here.

@junioralmeida-82 junioralmeida-82 self-assigned this May 14, 2026
@junioralmeida-82 junioralmeida-82 requested a review from a team as a code owner May 14, 2026 19:11
@junioralmeida-82 junioralmeida-82 added enhancement PowerShell Module Release for JumpCloud PowerShell Module patch labels May 14, 2026
Comment thread PowerShell/Deploy/Build-Module.ps1 Outdated
Comment thread PowerShell/ModuleChangelog.md Outdated
Invoke-Git -Arguments:('commit -m ' + '"' + $CommitMessage + '";')
Invoke-Git -Arguments:('push origin ' + 'master' + ';')
#Invoke-Git -Arguments:('commit -m ' + '"' + $CommitMessage + '";')
#Invoke-Git -Arguments:('push origin ' + 'master' + ';')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Git commit and push permanently disabled in build

Medium Severity

Both git commit and git push commands are commented out, making Invoke-GitCommit a no-op that stages files and shows status but never commits or pushes. While the PR notes this is temporary "until a separate deploy card is addressed," shipping this to the main branch means any CI/CD pipeline depending on this function will silently fail to publish changes.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6048ec3. Configure here.

Comment thread PowerShell/JumpCloud Module/JumpCloud.psd1 Outdated
Copy link
Copy Markdown
Contributor

@jworkmanjc jworkmanjc left a comment

Choose a reason for hiding this comment

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

The Acceptance Criteria for the card could be more clear but in general I want the Build-Module script to call all of the required build functions:
Get-Config / dependencies → Build-Module →SdkSync/jcapiToSupportSync.ps1 → Build-HelpFiles → Build-PesterTestFiles → BuildNuspecFromPsd1.

Right now the build script is only updating the Module Manifest (.psd1) file so this card can not be marked complete yet.

My aim is to have developers perform work in the module, then run ./Build-Module.ps1 -ReleaseType patch and have that function call perform the work it's doing today and run:
SdkSync/jcapiToSupportSync.ps1
Build-HelpFiles
Build-PesterTestFiles
BuildNuspecFromPsd1

These scripts need to be included in Build-Module in order to mark this work ready for review. The SDK functions can be updated outside of this this repository, when we cut a new release it's important to keep these functions that we autogenerate in sync with our latest powershell release.

Help Files should be generated if we are developing so having the build-module function call build-helpfiles would be important here.

Pester tests are generated automatically if a developer runs Build-PesterTestFiles, these have been forgotten previously so in my opinion they should just be included in the build-module script.

BuildNuspecFromPsd1 this is probably out of scope looking at this now but we did have it in the card. I think CI processes this and we really don't need to build this into the module.

& $BuildTestsPath
}
else {
Write-Warning "Build-PesterTestFiles script not found at $BuildTestsPath"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Split } else { causes PowerShell parse error

Medium Severity

The closing } of the if block and the else { keyword are on separate lines (line 100 vs 101), unlike all other if/else blocks in this file which use } else { on the same line. PowerShell treats a standalone } as a complete statement, so else on the next line is interpreted as an unrecognized command in interactive mode, dot-sourced contexts, and certain PS 5.1 execution scenarios. Given this PR targets cross-platform compatibility with PS 5.1 and 7+, this is a reliability concern.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 79d729a. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 3 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 07d64af. Configure here.

& $BuildHelpPath -ModuleName $ModuleName -ModulePath $ModuleFolder

# 4. Return the terminal to exactly where it was before.
Set-Location -Path $PreviousLocation
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Set-Location not restored if help script throws

Low Severity

The working directory is changed via Set-Location before calling & $BuildHelpPath, and restored afterward on line 90. If the help script throws a terminating error, Set-Location -Path $PreviousLocation is skipped, leaving the process in the "Docs" directory. Subsequent operations like Build-PesterTestFiles.ps1 would then execute from an unexpected location. A try/finally block would ensure the location is always restored.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 07d64af. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch PowerShell Module Release for JumpCloud PowerShell Module

Development

Successfully merging this pull request may close these issues.

2 participants