Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updatecli validate output #1290

Merged
merged 7 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 12 additions & 7 deletions updatecli/updatecli.d/update-plugins.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
param(
[Parameter(Position=0)]
[string] $pluginManagerJar = './plugin-manager.jar',
[Parameter(Position=1)]
[string] $JenkinsVersion
)

$JenkinsVersionX = $JenkinsVersion -replace '\d+$', 'x'

$pluginManagerJar = $ENV:PLUGIN_MANAGER_JAR_PATH ?? './plugin-manager.jar'
$pluginManagerVersion = $ENV:PLUGIN_MANAGER_VERSION ?? '2.12.8'

# check if jar does not exist, download it - useful for testing
Expand All @@ -29,23 +30,27 @@ $pom.Load($pomPath)
# Select Dependencies and Skip BOM
$dependencies = $pom.Project.DependencyManagement.Dependencies.Dependency | Select-Object -Skip 1

$changed = $false
foreach ($dependency in $dependencies) {
$artifact = $dependency.artifactId
$oldVersion = $dependency.version
$plugin = "${artifact}:${oldVersion}"
[string] $output = & $java -jar "$pluginManagerJar" --no-download --available-updates --output txt --jenkins-version "$JenkinsVersion" --plugins $plugin
if ($output -ne $plugin) {
[string] $output = & $java -jar "$pluginManagerJar" --no-download --available-updates --output txt --jenkins-version "$JenkinsVersion" --plugins "$plugin"
if ($null -ne $output -and $output -ne $plugin) {
# Example output:
# credentials:2.6.1.1

# Grab the version number
$newVersion = $output.Split(':')[-1]
Write-Output "Changed $artifact from $oldVersion to $newVersion"
$dependency.version = $newVersion
$changed = $true
}
}

$utf8WithoutBom = New-Object System.Text.UTF8Encoding($false)
$streamWriter = New-Object System.IO.StreamWriter($pomPath, $false, $utf8WithoutBom)
$pom.Save($streamWriter)
$streamWriter.Close()
if ($changed) {
$utf8WithoutBom = New-Object System.Text.UTF8Encoding($false)
$streamWriter = New-Object System.IO.StreamWriter($pomPath, $false, $utf8WithoutBom)
$pom.Save($streamWriter)
$streamWriter.Close()
}
10 changes: 5 additions & 5 deletions updatecli/updatecli.d/update-plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,35 +124,35 @@ targets:
sourceid: jenkins2.289.x
kind: shell
spec:
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1 {{ requiredEnv .github.jar }}
scmid: github
jenkins2.303.x:
name: 'Update 2.303.x plugins'
sourceid: jenkins2.303.x
kind: shell
spec:
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1 {{ requiredEnv .github.jar }}
scmid: github
jenkins2.319.x:
name: 'Update 2.319.x plugins'
sourceid: jenkins2.319.x
kind: shell
spec:
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1 {{ requiredEnv .github.jar }}
scmid: github
jenkins2.332.x:
name: 'Update 2.332.x plugins'
sourceid: jenkins2.332.x
kind: shell
spec:
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1 {{ requiredEnv .github.jar }}
scmid: github
jenkins2.346.x:
name: 'Update 2.346.x plugins'
sourceid: jenkins2.346.x
kind: shell
spec:
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1 {{ requiredEnv .github.jar }}
Copy link
Member Author

Choose a reason for hiding this comment

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

@olblak look at this hack to pass path for the jar 😅

scmid: github
pullrequests:
default:
Expand Down
1 change: 1 addition & 0 deletions updatecli/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ github:
owner: "jenkinsci"
repository: "bom"
branch: "master"
jar: "PLUGIN_MANAGER_JAR_PATH"