Try to update the jl
Beffroi/WinDiagnostics/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Dandaedre 2026-09-14 18:16:43 +02:00
parent df7ed5f0a7
commit 623a32165d
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
3 changed files with 80 additions and 78 deletions

3
.gitignore vendored
View File

@ -160,3 +160,6 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Jenkins workspace-local PowerShell modules
.tools/

125
Jenkinsfile vendored
View File

@ -1,101 +1,55 @@
// Jenkins CI for WinDiagnostics
// Static validation only: the diagnostic script itself targets Windows.
//
// Linux agent requirements:
// - git
// - curl
// - tar
// - sha256sum
// - network access to GitHub and PowerShell Gallery
//
// PowerShell is downloaded as a portable archive into the workspace.
// PSScriptAnalyzer is installed into a workspace-local module directory.
// FreeBSD agent requirements: git and the shells/powershell package.
// Install once as root: pkg install git powershell
// Label the Jenkins node "freebsd". See README.md for setup details.
// PSScriptAnalyzer is saved into a workspace-local module directory.
pipeline {
agent {
label 'linux'
label 'freebsd'
}
options {
timestamps()
ansiColor('xterm')
disableConcurrentBuilds()
}
environment {
POWERSHELL_TELEMETRY_OPTOUT = '1'
// Pin the CI runtime for reproducible builds.
PWSH_VERSION = '7.6.6'
PWSH_HOME = "${WORKSPACE}/.tools/powershell-7.6.6"
PWSH = "${WORKSPACE}/.tools/powershell-7.6.6/pwsh"
// FreeBSD packages install executables under /usr/local/bin.
PATH = "/usr/local/bin:/usr/local/sbin:${env.PATH}"
PWSH = 'pwsh'
// Keep installed PowerShell modules inside the Jenkins workspace.
PS_MODULE_HOME = "${WORKSPACE}/.tools/psmodules"
}
stages {
stage('Bootstrap PowerShell') {
stage('Check FreeBSD prerequisites') {
steps {
sh '''
set -eu
mkdir -p "$WORKSPACE/.tools"
ARCH="$(uname -m)"
case "$ARCH" in
x86_64|amd64)
PWSH_ARCH="x64"
PWSH_SHA256="DDBC4A2D113BBD46D283CFEDCBCD117A70CAEFD7673F41F2B4E0000BADF103BC"
;;
aarch64|arm64)
PWSH_ARCH="arm64"
PWSH_SHA256="924829E54C983648F6F1419A2DC7F9433C861B2FB5BD57736FF096C24F133729"
;;
*)
echo "Unsupported Linux architecture: $ARCH" >&2
exit 1
;;
esac
PACKAGE="powershell-${PWSH_VERSION}-linux-${PWSH_ARCH}.tar.gz"
URL="https://github.com/PowerShell/PowerShell/releases/download/v${PWSH_VERSION}/${PACKAGE}"
ARCHIVE="$WORKSPACE/.tools/$PACKAGE"
if [ -x "$PWSH" ]; then
CURRENT_VERSION="$($PWSH -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()')"
if [ "$CURRENT_VERSION" = "$PWSH_VERSION" ]; then
echo "Using cached PowerShell $CURRENT_VERSION"
"$PWSH" --version
exit 0
fi
echo "Cached PowerShell version is $CURRENT_VERSION; reinstalling $PWSH_VERSION."
rm -rf "$PWSH_HOME"
if [ "$(uname -s)" != "FreeBSD" ]; then
echo "This pipeline requires a FreeBSD agent labeled freebsd." >&2
exit 1
fi
echo "Downloading PowerShell $PWSH_VERSION for $PWSH_ARCH..."
curl \
--fail \
--location \
--retry 3 \
--retry-delay 2 \
--output "$ARCHIVE" \
"$URL"
if ! command -v git >/dev/null 2>&1 || ! command -v "$PWSH" >/dev/null 2>&1; then
echo "Missing git or pwsh. On the agent, install as root: pkg install git powershell" >&2
exit 1
fi
echo "Verifying SHA-256..."
printf '%s %s\n' "$PWSH_SHA256" "$ARCHIVE" | sha256sum --check -
rm -rf "$PWSH_HOME"
mkdir -p "$PWSH_HOME"
tar -xzf "$ARCHIVE" -C "$PWSH_HOME"
chmod 755 "$PWSH"
rm -f "$ARCHIVE"
echo "PowerShell installed locally:"
"$PWSH" --version
"$PWSH" -NoLogo -NoProfile -NonInteractive -Command '
$ErrorActionPreference = "Stop"
if ($PSVersionTable.PSVersion.Major -lt 7) {
throw "PowerShell 7 or later is required."
}
$PSVersionTable | Out-String | Write-Host
'
'''
}
}
@ -126,10 +80,12 @@ pipeline {
"$PWSH" -NoLogo -NoProfile -NonInteractive -Command '
$ErrorActionPreference = "Stop"
$files = @(Get-ChildItem -Path . -Recurse -File |
Where-Object {
$_.Extension -in ".ps1", ".psm1", ".psd1"
})
# Limit validation to source files, excluding workspace caches.
$paths = @(git -c core.quotePath=false ls-files -- "*.ps1" "*.psm1" "*.psd1")
if ($LASTEXITCODE -ne 0) {
throw "Unable to list tracked PowerShell files."
}
$files = @($paths | ForEach-Object { Get-Item -LiteralPath $_ })
if ($files.Count -eq 0) {
throw "No PowerShell files found."
@ -153,7 +109,7 @@ pipeline {
$failed = $true
foreach ($parseError in $errors) {
Write-Error (
Write-Host (
"{0}:{1}:{2}: {3}" -f
$file.FullName,
$parseError.Extent.StartLineNumber,
@ -203,11 +159,24 @@ pipeline {
$module = Get-Module PSScriptAnalyzer
Write-Host "PSScriptAnalyzer version: $($module.Version)"
# Limit validation to source files, excluding workspace caches.
$paths = @(git -c core.quotePath=false ls-files -- "*.ps1" "*.psm1" "*.psd1")
if ($LASTEXITCODE -ne 0) {
throw "Unable to list tracked PowerShell files."
}
$files = @($paths | ForEach-Object { Get-Item -LiteralPath $_ })
if ($files.Count -eq 0) {
throw "No PowerShell files found."
}
$issues = @(
Invoke-ScriptAnalyzer `
-Path . `
-Recurse `
-Severity Error,Warning
foreach ($file in $files) {
Invoke-ScriptAnalyzer `
-Path $file.FullName `
-Severity Error,Warning `
-ErrorAction Stop
}
)
if ($issues.Count -gt 0) {

View File

@ -407,3 +407,33 @@ $src = irm 'https://proxy.dandaedre.com/gitea/Dandaedre/WinDiagnostics/raw/branc
# Local Full
.\WindowsMaintenanceReport.ps1 -Full
```
## Jenkins validation on FreeBSD
The `Jenkinsfile` runs static checks on a Jenkins agent labeled `freebsd`.
It parses tracked `.ps1`, `.psm1`, and `.psd1` files, runs PSScriptAnalyzer,
and checks for the structured JSON report markers. Parser and analyzer errors
fail the build; analyzer warnings are reported. The Windows diagnostics script
is never executed by CI, so these checks do not verify its Windows runtime behavior.
On the FreeBSD agent, install the native runtime and Git once as root:
```sh
pkg install git powershell
```
PowerShell is provided by the FreeBSD `shells/powershell` port. Use a FreeBSD
release and package repository that provides it. Linux PowerShell archives
are not native FreeBSD executables.
Configure the Jenkins node with the `freebsd` label and a working Jenkins agent
(Java and Git checkout). Ensure `/usr/local/bin` is on the agent service's PATH
for the initial checkout; the pipeline also adds it for its build steps.
Verify `pwsh -NoLogo -NoProfile -NonInteractive -Command '$PSVersionTable'`
as the Jenkins service user. No root access is needed during builds.
The agent needs HTTPS access to PowerShell Gallery and its download endpoints
when PSScriptAnalyzer is first saved. Modules are cached in `.tools/psmodules`
inside the writable workspace. The pipeline uses the installed PowerShell 7+
runtime rather than downloading a Linux binary. Jenkins needs Declarative
Pipeline and Timestamper support; the AnsiColor plugin is not required.