diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 000000000..b70294cce --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,26 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:base", ":semanticCommitsDisabled", "schedule:daily"], + "enabledManagers": ["regex"], + "automerge": true, + "regexManagers": [ + { + "fileMatch": ["prep-pct.sh"], + "matchStrings": ["pct_version=(?.*?)\n"], + "depNameTemplate": "org.jenkins-ci.tests:plugins-compat-tester-cli", + "datasourceTemplate": "maven", + "registryUrlTemplate": "https://repo.jenkins-ci.org/releases/" + }, + { + "fileMatch": ["sample-plugin/pom.xml"], + "matchStrings": [ + "(?.*?)" + ], + "depNameTemplate": "org.jenkins-ci.main:jenkins-war", + "datasourceTemplate": "maven", + "registryUrlTemplate": "https://repo.jenkins-ci.org/releases/" + } + ], + "labels": ["dependencies"], + "rebaseWhen": "conflicted" +} diff --git a/.github/workflows/action-updatecli.yaml b/.github/workflows/action-updatecli.yaml deleted file mode 100644 index 2bf62be0c..000000000 --- a/.github/workflows/action-updatecli.yaml +++ /dev/null @@ -1,52 +0,0 @@ -name: updatecli - -on: - workflow_dispatch: - pull_request: - push: - branches: - - master - schedule: - # * is a special character in YAML so you have to quote this string - # Run once a day - - cron: '0 0 * * *' - -env: - PLUGIN_MANAGER_VERSION: '2.12.8' - -jobs: - updatecli: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install updatecli - uses: updatecli/updatecli-action@v2 - - - name: Install Jenkins Plugin Installation Manager Tool - run: | - 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: Generate updatecli manifests - shell: pwsh - run: | - Set-PSRepository -Name PSGallery -InstallationPolicy Trusted - ./updatecli/generate-manifests.ps1 - - - name: Diff - continue-on-error: true - run: | - updatecli diff --config updatecli/updatecli.d --values updatecli/values.yaml - env: - UPDATECLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Apply - if: github.ref == 'refs/heads/master' - run: | - updatecli apply --config updatecli/updatecli.d --values updatecli/values.yaml - env: - UPDATECLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 24e54a52b..eb28baf1b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,5 @@ logs/ megawar.war pct.jar plugin-manager.jar -!updatecli.d/ -updatecli.d/* -!updatecli.d/plugin-compat-tester.yml .env .envrc diff --git a/prep-pct.sh b/prep-pct.sh index bf35ba42d..d163210b0 100644 --- a/prep-pct.sh +++ b/prep-pct.sh @@ -2,7 +2,7 @@ set -euxo pipefail cd "$(dirname "${0}")" -# Tracked by ./updatecli/updatecli.d/plugin-compat-tester.yml +# Tracked by .github/renovate.json pct_version=1337.vd1853588a_0c6 pct="$(mvn -Dexpression=settings.localRepository -q -DforceStdout help:evaluate)/org/jenkins-ci/tests/plugins-compat-tester-cli/${pct_version}/plugins-compat-tester-cli-${pct_version}.jar" [ -f "${pct}" ] || mvn dependency:get -Dartifact=org.jenkins-ci.tests:plugins-compat-tester-cli:${pct_version}:jar -DremoteRepositories=repo.jenkins-ci.org::default::https://repo.jenkins-ci.org/public/,incrementals::default::https://repo.jenkins-ci.org/incrementals/ -Dtransitive=false diff --git a/updatecli/generate-manifests.ps1 b/updatecli/generate-manifests.ps1 deleted file mode 100644 index 89d48124f..000000000 --- a/updatecli/generate-manifests.ps1 +++ /dev/null @@ -1,250 +0,0 @@ -if ($null -eq $ENV:GITHUB_WORKSPACE) { - $root = "$PSScriptRoot/.." | Resolve-Path -} else { - $root = $ENV:GITHUB_WORKSPACE -} - -function EnsureModuleInstalled ($name) { - $module = Get-InstalledModule -Name $name -ErrorAction SilentlyContinue - if ($null -eq $module) { - Install-Module -Name $name -Scope CurrentUser -AllowClobber - } else { - Import-Module $name - } -} - -EnsureModuleInstalled "powershell-yaml" - -$manifestDirectory = "$root/updatecli/updatecli.d" - -if ([System.IO.Directory]::Exists($manifestDirectory) -eq $false) { - New-Item -Force -ItemType Directory -Path $manifestDirectory | Out-Null -} - -# Get current bom versions based on directory structure afterwards sort by version number ascending -$bills = Get-ChildItem "$root/bom-*" -Directory ` - | Select-Object -ExpandProperty Name ` - | Where-Object { $_ -ne "bom-weekly" } ` - | ForEach-Object { [System.Version]$($_ -replace '^bom-(\d+\.\d+?)\.x$','$1') } ` - | Sort-Object ` - | ForEach-Object { "bom-$($_.Major).$($_.Minor).x" } - -$latestStableBom = $bills[-1] -$bills = @("bom-weekly") + $bills - -$pomPath = "sample-plugin/pom.xml" -$pom = New-Object System.Xml.XmlDocument -$pom.PreserveWhitespace = $true -$pom.Load($pomPath) - -$jenkinsVersions = @{} - -$jenkinsVersions["weekly"] = $pom.project.properties."jenkins.version" - -$pom.project.profiles.profile | ForEach-Object { - $jenkinsVersions[$_.id] = $_.properties."jenkins.version" -} - -foreach ($bom in $bills) { - $updateJenkinsManifest = [ordered]@{ - scms = [ordered]@{ - github = [ordered]@{ - kind = "github" - spec = [ordered]@{ - user = '{{ .github.user }}' - email = '{{ .github.email }}' - owner = '{{ .github.owner }}' - repository = '{{ .github.repository }}' - branch = '{{ .github.branch }}' - username = '{{ .github.username }}' - token = '{{ requiredEnv .github.token }}' - } - } - } - sources = [ordered]@{} - conditions = [ordered]@{} - targets = [ordered]@{} - actions = [ordered]@{} - } - - $bomVersion = $bom -replace "bom-", "" - $jenkinsVersion = $jenkinsVersions[$bomVersion] - - $updateJenkinsManifestPath = "$manifestDirectory/update-jenkins-$bomVersion.yaml" - - if ($bom -eq "bom-weekly") { - $updateJenkinsManifest.sources["jenkins"] = [ordered]@{ - name = "Get Last jenkins Weekly Version" - kind = "jenkins" - spec = [ordered]@{ - release = "weekly" - github = [ordered]@{ - token = '{{ requiredEnv .github.token }}' - username = '{{ .github.username }}' - } - } - } - } else { - # remove .x from z.y.x and replace literal dot with escaped dot - $bomVersionPattern = $bomVersion -replace ".x", "" - if ($latestStableBom -eq $bom) { - $bomVersionPattern = "jenkins-$bomVersionPattern.1$" - } else { - $bomVersionPattern = "jenkins-$bomVersionPattern.\d+$" - } - $bomVersionPattern = $bomVersionPattern -replace "\.", "\." - $updateJenkinsManifest.sources["jenkins"] = [ordered]@{ - name = "Get last Jenkins stable version" - kind = "githubrelease" - spec = [ordered]@{ - owner = "jenkinsci" - repository = "jenkins" - token = '{{ requiredEnv .github.token }}' - versionfilter = [ordered]@{ - kind = "regex" - pattern = $bomVersionPattern - } - } - transformers = @(@{ - trimprefix = "jenkins-" - }) - } - } - - $updateJenkinsManifest.conditions["jenkins"] = [ordered]@{ - name = "Test if Jenkins stable published" - kind = "maven" - sourceid = "jenkins" - spec = [ordered]@{ - url = "repo.jenkins-ci.org" - repository = "releases" - groupId = "org.jenkins-ci.main" - artifactId = "jenkins-war" - } - } - $updateJenkinsManifest.targets["jenkins"] = [ordered]@{ - name = "Update Jenkins version" - sourceid = "jenkins" - scmid = "github" - kind = "shell" - spec = [ordered]@{ - command = "pwsh -NoProfile -File {{ requiredEnv `"GITHUB_WORKSPACE`" }}/updatecli/update-jenkins.ps1 $bomVersion" - } - } - $updateJenkinsManifest.actions["jenkins"] = [ordered]@{ - title = "Bump jenkins.version from $jenkinsVersion to {{ source `"jenkins`" }} for bom-$bomVersion" - kind = "github/pullrequest" - scmid = "github" - targets = @("jenkins") - spec = [ordered]@{ - labels = @("dependencies") - automerge = $true - mergemethod = "squash" - usetitleforautomerge = $true - } - } - - ConvertTo-Yaml -Data $updateJenkinsManifest -OutFile $updateJenkinsManifestPath -Force - - if ($bom -eq "bom-weekly") { - # weekly bom is handled by dependabot - continue - } - - $pomPath = "$bom/pom.xml" - $pom = New-Object System.Xml.XmlDocument - $pom.PreserveWhitespace = $true - $pom.Load($pomPath) - - $dependencies = $pom.Project.DependencyManagement.Dependencies.Dependency | Select-Object -Skip 1 - - - foreach ($dependency in $dependencies) { - $artifactId = $dependency.artifactId - $groupId = $dependency.groupId - $version = $dependency.version - $name = $artifactId - if ($version.StartsWith("$")) { - # remove the dollar sign and curly braces - $name = $version -replace '^\${(.+?)}$', '$1' - $version = $pom.project.properties."$name" - } - - $updatePluginsManifestPath = "$manifestDirectory/update-plugin-$bomVersion-$artifactId-$version.yaml" - - if ([System.IO.File]::Exists($updatePluginsManifestPath)) { - continue - } - - $updatePluginsManifest = [ordered]@{ - scms = [ordered]@{ - github = [ordered]@{ - kind = "github" - spec = [ordered]@{ - user = '{{ .github.user }}' - email = '{{ .github.email }}' - owner = '{{ .github.owner }}' - repository = '{{ .github.repository }}' - branch = '{{ .github.branch }}' - username = '{{ .github.username }}' - token = '{{ requiredEnv .github.token }}' - } - } - } - sources = [ordered]@{} - conditions = [ordered]@{} - targets = [ordered]@{} - actions = [ordered]@{} - } - - $updatePluginsManifest.sources["plugin"] = [ordered]@{ - name = "Get last $name version" - kind = "shell" - spec = @{ - command = "java -jar {{ requiredEnv `"PLUGIN_MANAGER_JAR_PATH`" }} --no-download --available-updates --output txt --jenkins-version $jenkinsVersion --plugins ${artifactId}:${version}" - } - transformers = @( - @{ - findsubmatch = @{ - pattern = '(.*?):(.*)' - captureindex = 2 - } - } - ) - } - $updatePluginsManifest.conditions["plugin"] = [ordered]@{ - name = "Test if $name is published" - kind = "maven" - sourceid = "plugin" - spec = [ordered]@{ - url = "repo.jenkins-ci.org" - repository = "releases" - groupId = $groupId - artifactId = $artifactId - } - } - $updatePluginsManifest.targets["plugin"] = [ordered]@{ - name = "Update $name" - sourceid = "plugin" - scmid = "github" - kind = "shell" - spec = @{ - command = "pwsh -NoProfile -File {{ requiredEnv `"GITHUB_WORKSPACE`" }}/updatecli/update-plugin.ps1 $pomPath $name" - } - } - $updatePluginsManifest.actions["plugin"] = [ordered]@{ - title = "Bump $name from $version to {{ source `"plugin`" }} in /bom-$bomVersion" - kind = "github/pullrequest" - scmid = "github" - targets = @("plugin") - spec = [ordered]@{ - labels = @("dependencies") - automerge = $true - mergemethod = "squash" - usetitleforautomerge = $true - } - } - - ConvertTo-Yaml -Data $updatePluginsManifest -OutFile $updatePluginsManifestPath -Force - } -} diff --git a/updatecli/update-jenkins.ps1 b/updatecli/update-jenkins.ps1 deleted file mode 100644 index 440b47db9..000000000 --- a/updatecli/update-jenkins.ps1 +++ /dev/null @@ -1,48 +0,0 @@ -param( - [Parameter(Position = 0)] - [string] $BomVersion, - [Parameter(Position = 1)] - [string] $JenkinsVersion -) - -$changed = $false -if ($null -eq $ENV:DRY_RUN) { - $ENV:DRY_RUN = $false -} - -$pomPath = "sample-plugin/pom.xml" -$pom = New-Object System.Xml.XmlDocument -$pom.PreserveWhitespace = $true -$pom.Load($pomPath) - -if ($BomVersion -eq "weekly") { - $currentVersion = $pom.project.properties.'jenkins.version' - if ($null -ne $currentVersion -and $currentVersion -ne $JenkinsVersion) { - $changed = $true - $pom.project.properties.'jenkins.version' = $JenkinsVersion - } -} else { - $pomProfile = $pom.project.profiles.profile | Where-Object { $_.id -eq $BomVersion } | Select-Object -First 1 - if ($null -eq $pomProfile) { - Write-Host "Profile for Jenkins version $BomVersion not found in $pomPath" - exit 1 - } - - $currentVersion = $pomProfile.properties.'jenkins.version' - if ($null -ne $currentVersion -and $currentVersion -ne $JenkinsVersion) { - $changed = $true - $pomProfile.Properties.'jenkins.version' = $JenkinsVersion - } -} - -if ($changed) { - Write-Output "$JenkinsVersion" - - if ($ENV:DRY_RUN -eq $false) { - $utf8WithoutBom = New-Object System.Text.UTF8Encoding($false) - $streamWriter = New-Object System.IO.StreamWriter($pomPath, $false, $utf8WithoutBom) - $pom.Save($streamWriter) - $streamWriter.Close() - (Get-Content $pomPath) -creplace 'utf-8', 'UTF-8' | Set-Content $pomPath - } -} diff --git a/updatecli/update-plugin.ps1 b/updatecli/update-plugin.ps1 deleted file mode 100644 index b82e3309e..000000000 --- a/updatecli/update-plugin.ps1 +++ /dev/null @@ -1,51 +0,0 @@ -param( - [Parameter(Position=0)] - [string] $PomPath, - [Parameter(Position=1)] - [string] $Artifact, - [Parameter(Position=2)] - [string] $NewVersion -) - -$changed = $false -if ($null -eq $ENV:DRY_RUN) { - $ENV:DRY_RUN = $false -} - -$pom = New-Object System.Xml.XmlDocument -$pom.PreserveWhitespace = $true -$pom.Load($PomPath) - -# Select Dependencies and Skip BOM -$dependencies = $pom.Project.DependencyManagement.Dependencies.Dependency | Select-Object -Skip 1 - -$plugins = @($dependencies | Where-Object { $_.artifactid -eq $Artifact }) -$property = $pom.project.properties."$Artifact" - -if ($null -ne $property -and $property -ne $NewVersion) { - Write-Host "1 Updating $Artifact to $NewVersion" - $changed = $true - $pom.project.properties."$Artifact" = $NewVersion -} - -if ($plugins.Count -ne 0 -and $plugins[0].version -ne $NewVersion) { - $changed = $true - $plugins | ForEach-Object { - $_.version = $NewVersion - } -} - -# TODO keeps on offering unwanted plugin updates in LTS lines -$changed = $false - -if ($changed) { - Write-Output $NewVersion - - if ($ENV:DRY_RUN -eq $false) { - $utf8WithoutBom = New-Object System.Text.UTF8Encoding($false) - $streamWriter = New-Object System.IO.StreamWriter($PomPath, $false, $utf8WithoutBom) - $pom.Save($streamWriter) - $streamWriter.Close() - (Get-Content $PomPath) -creplace 'utf-8', 'UTF-8' | Set-Content $PomPath - } -} diff --git a/updatecli/updatecli.d/plugin-compat-tester.yml b/updatecli/updatecli.d/plugin-compat-tester.yml deleted file mode 100644 index cf33f2e55..000000000 --- a/updatecli/updatecli.d/plugin-compat-tester.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -name: Bump `plugin-compat-tester` - -scms: - default: - kind: github - spec: - user: "{{ .github.user }}" - email: "{{ .github.email }}" - owner: "{{ .github.owner }}" - repository: "{{ .github.repository }}" - token: "{{ requiredEnv .github.token }}" - username: "{{ .github.username }}" - branch: "{{ .github.branch }}" - -sources: - pctVersion: - kind: githubrelease - spec: - owner: "jenkinsci" - repository: "plugin-compat-tester" - token: "{{ requiredEnv .github.token }}" - username: "{{ .github.username }}" - -targets: - setPctInPrep: - sourceid: pctVersion - name: "Change the plugin-compat-tester version" - kind: file - spec: - file: prep-pct.sh - matchpattern: >- - pct_version=(.*) - replacepattern: >- - pct_version={{ source `pctVersion` }} - scmid: default - -actions: - default: - kind: github/pullrequest - scmid: default - title: Bump plugin-compat-tester version to {{ source `pctVersion` }} - spec: - labels: - - dependencies - - full-test diff --git a/updatecli/values.yaml b/updatecli/values.yaml deleted file mode 100644 index 971c817e8..000000000 --- a/updatecli/values.yaml +++ /dev/null @@ -1,8 +0,0 @@ -github: - user: "GitHub Actions" - email: "41898282+github-actions[bot]@users.noreply.github.com" - username: "github-actions" - token: "UPDATECLI_GITHUB_TOKEN" - owner: "jenkinsci" - repository: "bom" - branch: "master"