plugin-installation-manager-tool icon indicating copy to clipboard operation
plugin-installation-manager-tool copied to clipboard

Default jenkins.war path wrong since 2.332.1

Open dbnicholson opened this issue 3 years ago • 1 comments

Jenkins and plugins versions report

Environment

Jenkins: 2.332.1 OS: Linux - 5.10.0-13-cloud-amd64

ace-editor:1.1 amazon-ecr:1.7 ansicolor:1.0.1 antisamy-markup-formatter:2.7 apache-httpcomponents-client-4-api:4.5.13-1.0 authentication-tokens:1.4 aws-credentials:191.vcb_f183ce58b_9 aws-java-sdk-ec2:1.12.163-315.v2b_716ec8e4df aws-java-sdk-ecr:1.12.163-315.v2b_716ec8e4df aws-java-sdk-minimal:1.12.163-315.v2b_716ec8e4df bootstrap4-api:4.6.0-3 bootstrap5-api:5.1.3-6 bouncycastle-api:2.25 branch-api:2.1044.v2c007e51b_87f build-name-setter:2.2.0 buildresult-trigger:0.17 caffeine-api:2.9.2-29.v717aac953ff3 checks-api:1.7.2 cloudbees-folder:6.714.v79e858ef76a_2 cobertura:1.17 code-coverage-api:2.0.4 command-launcher:1.6 credentials:1087.v16065d268466 credentials-binding:1.27.1 data-tables-api:1.11.4-4 description-setter:1.10 display-url-api:2.3.6 docker-commons:1.19 docker-java-api:3.1.5.2 docker-plugin:1.2.6 docker-workflow:1.28 durable-task:495.v29cd95ec10f2 ec2:1.68 echarts-api:5.3.0-2 email-ext:2.87 extended-read-permission:3.2 font-awesome-api:6.0.0-1 forensics-api:1.12.0 ghprb:1.42.2 git:4.11.0 git-client:3.11.0 git-server:1.10 github:1.34.3 github-api:1.301-378.v9807bd746da5 greenballs:1.15.1 handlebars:3.0.8 hashicorp-vault-pipeline:1.3 hashicorp-vault-plugin:336.v182c0fbaaeb7 jackson2-api:2.13.2-260.v43d711474c77 javax-activation-api:1.2.0-2 javax-mail-api:1.6.2-5 jaxb:2.3.0 jdk-tool:1.0 jquery3-api:3.6.0-2 jsch:0.1.55.2 junit:1.58 ldap:2.8 lockable-resources:2.14 mailer:408.vd726a_1130320 matrix-auth:3.1 matrix-project:758.v7a_ea_491852f3 momentjs:1.1.1 node-iterator-api:1.5.1 okhttp-api:4.9.3-105.vb96869f8ac3a parameterized-trigger:2.44 pipeline-build-step:2.16 pipeline-graph-analysis:188.v3a01e7973f2c pipeline-input-step:446.vf27b_0b_83500e pipeline-milestone-step:100.v60a_03cd446e1 pipeline-model-api:2.2075.vce74e77b_ce40 pipeline-model-definition:2.2075.vce74e77b_ce40 pipeline-model-extensions:2.2075.vce74e77b_ce40 pipeline-rest-api:2.23 pipeline-stage-step:291.vf0a8a7aeeb50 pipeline-stage-tags-metadata:2.2075.vce74e77b_ce40 pipeline-stage-view:2.23 pipeline-utility-steps:2.12.0 plain-credentials:1.8 plugin-util-api:2.16.0 popper-api:1.16.1-2 popper2-api:2.11.4-1 scm-api:595.vd5a_df5eb_0e39 script-security:1145.vb_cf6cf6ed960 snakeyaml-api:1.29.1 ssh-agent:1.24.1 ssh-credentials:1.19 ssh-slaves:1.806.v2253cedd3295 sshd:3.1.0 structs:308.v852b473a2b8c token-macro:285.vff7645a_56ff0 trilead-api:1.0.13 variant:1.4 windows-slaves:1.0 workflow-aggregator:2.7 workflow-api:1143.v2d42f1e9dea_5 workflow-basic-steps:941.vdfe1b_a_132c64 workflow-cps:2683.vd0a_8f6a_1c263 workflow-cps-global-lib:564.ve62a_4eb_b_e039 workflow-durable-task-step:1128.v8c259d125340 workflow-job:1174.vdcb_d054cf74a_ workflow-multibranch:711.vdfef37cda_816 workflow-scm-step:2.13 workflow-step-api:622.vb_8e7c15b_c95a_ workflow-support:815.vd60466279fc8

Paste the output here

What Operating System are you using (both controller, and any agents involved in the problem)?

Linux

Reproduction steps

  1. Run jenkins-plugin-manager without --war specified.

Expected Results

jenkins-plugin-manager finds jenkins.war at the default path and is able to get the Jenkins version from it.

Actual Results

jenkins.war isn't found and the Jenkins version can't be determined from it:

No war entered. Will use default of /usr/share/jenkins/jenkins.war
Unable to open /usr/share/jenkins/jenkins.war
Unable to get Jenkins version from the WAR file /usr/share/jenkins/jenkins.war

Anything else?

The default jenkins.war path on Linux changed from /usr/share/jenkins/jenkins.war to /usr/share/java/jenkins.war in jenkinsci/packaging#266. Per JENKINS-41218, that's 2.332.1 and 2.335.

dbnicholson avatar Apr 05 '22 16:04 dbnicholson

Hmm requires docker images to move as well: https://github.com/jenkinsci/docker/blob/master/17/debian/bullseye/hotspot/Dockerfile#L87-L88

The defaults were built based around the docker images.

timja avatar Apr 05 '22 21:04 timja

Hey,

I am on Windows 11. The following command worked for me:

 java -jar C:/Users/tiwar/open-source/jenkins-plugin-manager-2.12.9.jar --plugin-file C:/Users/tiwar/open-source/plugins.txt --plugins delivery-pipeline-plugin:1.3.2 deployit-plugin

I added Jenkins.war at "C:\ProgramData\Jenkins" it worked fine.

How do I resolve this issue for Linux?

Jagrutiti avatar Jan 29 '23 13:01 Jagrutiti

Do I have to update the path to /usr/share/java/jenkins.war in Settings.java?

Jagrutiti avatar Jan 29 '23 13:01 Jagrutiti

I think that we want a list of valid locations for the jenkins.war file and search the list in case the first entry in the list is not found. That will allow us to retain compatibility with existing users and acknowledge that there are multiple locations where the jenkins.war can be found if it is not found in the first location that is checked.

MarkEWaite avatar Jan 29 '23 14:01 MarkEWaite

This would be my approach:

In a static file named DefaultPathsForWarFile.txt I shall add all the possible paths?

Then, I will read the file. Loop through each path until the file is found. If the file is found return the path else return null.

Does this sound good to you?

If yes, where shall I implement it? In bundlesPlugins() or in getJenkinsVersionFromWar()?

Jagrutiti avatar Jan 29 '23 16:01 Jagrutiti

An external file seems more complicated than necessary, especially because then that file needs to be copied into the jar file as a resource and accessed from the jar file as a resource.

I think you could declare an array of String in the Java class that implements getJenkinsVersionFromWar() so that the Java class includes the list of possible locations for the war file.

MarkEWaite avatar Jan 29 '23 19:01 MarkEWaite

Dear @MarkEWaite,

Can I provide another approach instead of list of valid location to be added hard coded?

if yes, I hope my approach will be correct.

Steps

  • Location of Jenkins war file has gotten by System.getenv("JENKINS_HOME").
  • Based on the location which is returned from first step. it will be good to find war file.

Do you find this solution sounds good or not ?

muhammedSabbah avatar Mar 05 '23 19:03 muhammedSabbah

  • Location of Jenkins war file has gotten by System.getenv("JENKINS_HOME").

I don't think that will have the result that you want. The JENKINS_HOME directory does not include a copy of the war file, at least not in my installation that was done with the deb package as described in "Installing Jenkins".

MarkEWaite avatar Mar 05 '23 19:03 MarkEWaite