openshift / jenkins

Apache License 2.0
260 stars 447 forks source link

install-plugins.sh fails if plugin version is not specified, or is set to latest #1709

Closed marmijo closed 7 months ago

marmijo commented 12 months ago

The CoreOS team is trying to keep our layered Jenkins plugins updated by removing the version number in our plugins.txt.

Setting the plugin version to latest e.g. plugin-name:latest, or leaving the version blank, causes install-plugins.sh to fail because the version (blank, latest) doesnt match the installed version during this check, which verifies that the installed plugin is exactly the one specified by the user.

The script allows setting the version to latest or leaving blank, in which case the version will be set to latest. But when checking if the installed plugin matches the plugin specified in the input file, the version of latest or blank doesnt exist.

More specifically, if I set plugin-name:latest in my plugins.txt file, then it'll find and install the latest version, but this line will fail because plugin-name:latest cant be found in the list containing e.g. plugin-name:1.42.

Here are some relevant lines from the build log of the jenkins pod where I tried to set some plugins without versions and one with latest:

STEP 8/9: RUN /usr/libexec/s2i/assemble
---> Copying repository files ...
---> Installing 37 Jenkins plugins using /opt/openshift/plugins.txt ...
Creating initial locks...
Locking basic-branch-build-strategies
Locking generic-webhook-trigger
Locking github-oauth
Locking kubernetes-credentials-provider
Locking pipeline-github
Locking slack
Locking timestamper
Locking splunk-devops-extend
Locking splunk-devops
Locking antisamy-markup-formatter:latest

Analyzing war: /usr/lib/jenkins/jenkins.war
Checking JENKINS_WAR=/usr/lib/jenkins/jenkins.war

Analyzing war ... done

Downloading plugins...
Downloading plugin: basic-branch-build-strategies from https://updates.jenkins.io/download/plugins/basic-branch-build-strategies/latest/basic-branch-build-strategies.hpi
Downloading plugin: generic-webhook-trigger from https://updates.jenkins.io/download/plugins/generic-webhook-trigger/latest/generic-webhook-trigger.hpi
Downloading plugin: github-oauth from https://updates.jenkins.io/download/plugins/github-oauth/latest/github-oauth.hpi
Downloading plugin: kubernetes-credentials-provider from https://updates.jenkins.io/download/plugins/kubernetes-credentials-provider/latest/kubernetes-credentials-provider.hpi
Downloading plugin: pipeline-github from https://updates.jenkins.io/download/plugins/pipeline-github/latest/pipeline-github.hpi
Downloading plugin: slack from https://updates.jenkins.io/download/plugins/slack/latest/slack.hpi
Downloading plugin: timestamper from https://updates.jenkins.io/download/plugins/timestamper/latest/timestamper.hpi
Downloading plugin: splunk-devops-extend from https://updates.jenkins.io/download/plugins/splunk-devops-extend/latest/splunk-devops-extend.hpi
Downloading plugin: splunk-devops from https://updates.jenkins.io/download/plugins/splunk-devops/latest/splunk-devops.hpi
Downloading plugin: antisamy-markup-formatter from https://updates.jenkins.io/download/plugins/antisamy-markup-formatter/latest/antisamy-markup-formatter.hpi

Installed plugins:
...
...
antisamy-markup-formatter:162.v0e6ec0fcfcf6
basic-branch-build-strategies:81.v05e333931c7d
generic-webhook-trigger:1.87.0
github-oauth:588.vf696a_350572a_
kubernetes-credentials-provider:1.225.v14f9e6b_28f53
slack:684.v833089650554
timestamper:1.26
splunk-devops-extend:1.10.1
splunk-devops:1.10.1
...
...

Verifying Locked Plugins in Bundle...
Missing basic-branch-build-strategies
Missing generic-webhook-trigger
Missing github-oauth
Missing kubernetes-credentials-provider
Missing pipeline-github
Missing slack
Missing timestamper
Missing splunk-devops-extend
Missing splunk-devops
Missing antisamy-markup-formatter:latest

Some errors were encountered!
Plugin basic-branch-build-strategies not found in /opt/openshift/plugins/bundle-plugins.txt
Plugin generic-webhook-trigger not found in /opt/openshift/plugins/bundle-plugins.txt
Plugin github-oauth not found in /opt/openshift/plugins/bundle-plugins.txt
Plugin kubernetes-credentials-provider not found in /opt/openshift/plugins/bundle-plugins.txt
Plugin pipeline-github not found in /opt/openshift/plugins/bundle-plugins.txt
Plugin slack not found in /opt/openshift/plugins/bundle-plugins.txt
Plugin timestamper not found in /opt/openshift/plugins/bundle-plugins.txt
Plugin splunk-devops-extend not found in /opt/openshift/plugins/bundle-plugins.txt
Plugin splunk-devops not found in /opt/openshift/plugins/bundle-plugins.txt
Plugin antisamy-markup-formatter:latest not found in /opt/openshift/plugins/bundle-plugins.txt
Failed to install plugins.
error: build error: error building at STEP "RUN /usr/libexec/s2i/assemble": error while running runtime: exit status 1

The plugin's latest versions were correctly downloaded and installed, but the verification step failed because the version was not explicitly set in the plugins.txt file.

openshift-bot commented 9 months ago

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot commented 8 months ago

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

coreydaley commented 7 months ago

We need to keep the verification step as it is part of our process for ensuring that we have the correct plugin version.