Skip to content

Commit

Permalink
simplify updatecli pinned and add 2.346.x however pinned to .1 (#1279)
Browse files Browse the repository at this point in the history
  • Loading branch information
jetersen committed Jul 19, 2022
1 parent 1b6da73 commit a4b49d9
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 32 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/action-updatecli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
# Run once a day
- cron: '0 0 * * *'

env:
PLUGIN_MANAGER_VERSION: '2.12.8'

jobs:
updatecli:
runs-on: ubuntu-latest
Expand All @@ -18,15 +21,17 @@ jobs:

- name: Install updatecli # Until https://github.com/updatecli/updatecli/pull/336
run: |
curl -sSL https://github.com/updatecli/updatecli/releases/download/v0.23.2/updatecli_Linux_x86_64.tar.gz -o updatecli.tgz
curl -sSL https://github.com/updatecli/updatecli/releases/download/v0.27.0/updatecli_Linux_x86_64.tar.gz -o updatecli.tgz
tar xzf updatecli.tgz -C /usr/local/bin
updatecli version
rm -f updatecli.tgz
- name: Install Jenkins Plugin Installation Manager Tool
run: |
curl -sSL https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.12.3/jenkins-plugin-manager-2.12.3.jar -o "${GITHUB_WORKSPACE:-.}/plugin-manager.jar"
echo "PLUGIN_MANAGER_JAR_PATH=$GITHUB_WORKSPACE/plugin-manager.jar" >> $GITHUB_ENV
url="https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/$PLUGIN_MANAGER_VERSION/jenkins-plugin-manager-$PLUGIN_MANAGER_VERSION.jar"
path="${GITHUB_WORKSPACE:-.}/plugin-manager.jar"
curl -sSL "$url" -o "$path"
echo "PLUGIN_MANAGER_JAR_PATH=$path" >> $GITHUB_ENV
- name: Diff
continue-on-error: true
Expand Down
23 changes: 15 additions & 8 deletions updatecli/updatecli.d/update-plugins.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
param(
[string] $JenkinsVersion,
[string] $PluginManagerJar = './plugin-manager.jar'
[Parameter(Position=0)]
[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
if ([System.IO.File]::Exists($pluginManagerJar) -eq $false) {
curl -sSL "https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/$pluginManagerVersion/jenkins-plugin-manager-$pluginManagerVersion.jar" -o "$pluginManagerJar"
}

if (Get-Command 'java' -ErrorAction SilentlyContinue) {
$java = 'java'
} elseif ($IsLinux) {
Expand All @@ -25,14 +33,13 @@ foreach ($dependency in $dependencies) {
$artifact = $dependency.artifactId
$oldVersion = $dependency.version
$plugin = "${artifact}:${oldVersion}"
[string] $output = & $java -jar "$PluginManagerJar" --no-download --available-updates --jenkins-version "$JenkinsVersion" --plugins $plugin
if ($null -ne $output -and $output -inotlike '*No available updates*') {
[string] $output = & $java -jar "$pluginManagerJar" --no-download --available-updates --output txt --jenkins-version "$JenkinsVersion" --plugins $plugin
if ($output -ne $plugin) {
# Example output:
# Available updates:
# credentials (2.6.1) has an available update: 2.6.1.1
# credentials:2.6.1.1

# Grab the version number at the end of the line
$newVersion = $output.Trim().Split(' ')[-1]
# Grab the version number
$newVersion = $output.Split(':')[-1]
Write-Output "Changed $artifact from $oldVersion to $newVersion"
$dependency.version = $newVersion
}
Expand Down
13 changes: 0 additions & 13 deletions updatecli/updatecli.d/update-plugins.sh

This file was deleted.

45 changes: 37 additions & 8 deletions updatecli/updatecli.d/update-plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sources:
kind: regex
pattern: 'jenkins-2.289.\d+$'
transformers:
- trimPrefix: "jenkins-"
- trimprefix: "jenkins-"
jenkins2.303.x:
name: Get Last Jenkins Stable Version
kind: githubrelease
Expand All @@ -35,7 +35,7 @@ sources:
kind: regex
pattern: 'jenkins-2.303.\d+$'
transformers:
- trimPrefix: "jenkins-"
- trimprefix: "jenkins-"
jenkins2.319.x:
name: Get Last Jenkins Stable Version
kind: githubrelease
Expand All @@ -47,7 +47,7 @@ sources:
kind: regex
pattern: 'jenkins-2.319.\d+$'
transformers:
- trimPrefix: "jenkins-"
- trimprefix: "jenkins-"
jenkins2.332.x:
name: Get Last Jenkins Stable Version
kind: githubrelease
Expand All @@ -59,7 +59,19 @@ sources:
kind: regex
pattern: 'jenkins-2.332.\d+$'
transformers:
- trimPrefix: "jenkins-"
- trimprefix: "jenkins-"
jenkins2.346.x:
name: Get Last Jenkins Stable Version
kind: githubrelease
spec:
owner: "jenkinsci"
repository: "jenkins"
token: "{{ requiredEnv .github.token }}"
versionfilter:
kind: regex
pattern: 'jenkins-2.346.1$' # fix to x.x.1 until the next stable minor release
transformers:
- trimprefix: "jenkins-"
conditions:
jenkins2.289.x:
name: Test if Jenkins stable published
Expand Down Expand Up @@ -97,34 +109,50 @@ conditions:
repository: "releases"
groupid: "org.jenkins-ci.main"
artifactid: "jenkins-war"
jenkins2.346.x:
name: Test if Jenkins stable published
kind: maven
sourceid: jenkins2.346.x
spec:
url: "repo.jenkins-ci.org"
repository: "releases"
groupid: "org.jenkins-ci.main"
artifactid: "jenkins-war"
targets:
jenkins2.289.x:
name: 'Update 2.289.x plugins'
sourceid: jenkins2.289.x
kind: shell
spec:
command: bash ./updatecli/updatecli.d/update-plugins.sh
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1
scmid: github
jenkins2.303.x:
name: 'Update 2.303.x plugins'
sourceid: jenkins2.303.x
kind: shell
spec:
command: bash ./updatecli/updatecli.d/update-plugins.sh
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1
scmid: github
jenkins2.319.x:
name: 'Update 2.319.x plugins'
sourceid: jenkins2.319.x
kind: shell
spec:
command: bash ./updatecli/updatecli.d/update-plugins.sh
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1
scmid: github
jenkins2.332.x:
name: 'Update 2.332.x plugins'
sourceid: jenkins2.332.x
kind: shell
spec:
command: bash ./updatecli/updatecli.d/update-plugins.sh
command: pwsh -NoProfile -File ./updatecli/updatecli.d/update-plugins.ps1
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
scmid: github
pullrequests:
default:
Expand All @@ -136,6 +164,7 @@ pullrequests:
- jenkins2.303.x
- jenkins2.319.x
- jenkins2.332.x
- jenkins2.346.x
spec:
labels:
- dependencies
Expand Down

0 comments on commit a4b49d9

Please sign in to comment.