Docker:jenkins-plugin-manager提供:不允许参数:插件文件

gz5pxeao  于 2023-06-21  发布在  Jenkins
关注(0)|答案(1)|浏览(87)

故事:我有一个功能齐全的Docker Jenkins镜像,casc工作得很好。让它单独呆了半年,现在图像从DockerHub消失了。我已经尝试了一些其他的Jenkins图像,但就是不能让casc部分工作。
因为我不明白这些图像中包含了什么,所以我决定从头开始构建一个Jenkins图像,这样我就可以理解和控制每一步。正如我所提到的,我以前的图像运行完全正常,主要的区别是它使用了遗留的jenkins-plugin-cli.sh,这在图像中不再可用。
我找到了这个页面:https://medium.com/@nabujjal/build-docker-image-for-jenkins-with-centos-as-the-base-image-ad78ebba7251以及支持页面:仅https://github.com/jenkinsci/plugin-installation-manager-tool/blob/master/README.md#plugin-input-format我也尝试了2.10.0版本在前一页列出。
我不能忘记这个错误:
[10/12]运行java -jar/tmp/jenkins-plugin-manager-2.12.9.jar--war /usr/lib/jenkins/jenkins.war --plugin-file/root/.jenkins/plugins/plugins.txt

14 0.266不允许参数:???-plugin-file #14 0.266线程“main”中出现异常java.io.IOException:无法读取命令行参数#14 0.266 at io.jenkins.tools.pluginmanager.cli.Main.main(Main.java:26)#14 0.266原因:org.kohsuke.args4j.CmdLineException:不允许参数:???-plugin-file #14 0.266 at org.kohsuke.args4j.CmdLineParser.parseArgument(CmdLineParser.java:509)#14 0.266 at io.jenkins.tools.pluginmanager.cli.Main.main(Main.java:22)

我的Dockerfile是:

FROM centos:7
RUN yum install epel-release -y
RUN yum install fontconfig java-11-openjdk -y
RUN yum install wget -y
RUN wget --no-check-certificate -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
RUN rpm -import http://pkg.jenkins.io/redhat-stable/jenkins.io.key
#RUN yum install jenkins -y
RUN wget --no-check-certificate https://get.jenkins.io/war-stable/2.375.2/jenkins.war -P /usr/lib/jenkins
RUN wget https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.12.9/jenkins-plugin-manager-2.12.9.jar -P /tmp
COPY plugins.txt /root/.jenkins/plugins/
RUN java -jar /tmp/jenkins-plugin-manager-2.12.9.jar --war /usr/lib/jenkins/jenkins.war —-plugin-file /root/.jenkins/plugins/plugins.txt
RUN yum clean all
COPY casc.yaml /usr/local/jenkins-casc.yaml
ENV CASC_JENKINS_CONFIG /usr/local/jenkins-casc.yaml
CMD java -Djenkins.install.runSetupWizard=false -jar /usr/lib/jenkins/jenkins.war

完整输出:

% docker build -t centos7 . && docker run --name centos7 --rm -p 8080:8080 centos7
[+] Building 4.5s (14/16)                                                                                                                                                                                         
 => [internal] load build definition from Dockerfile                                                                                                                                                         0.0s
 => => transferring dockerfile: 1.00kB                                                                                                                                                                       0.0s
 => [internal] load .dockerignore                                                                                                                                                                            0.0s
 => => transferring context: 2B                                                                                                                                                                              0.0s
 => [internal] load metadata for docker.io/library/centos:7                                                                                                                                                  0.6s
 => [ 1/12] FROM docker.io/library/centos:7@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4                                                                                          0.0s
 => [internal] load build context                                                                                                                                                                            0.0s
 => => transferring context: 62B                                                                                                                                                                             0.0s
 => CACHED [ 2/12] RUN yum install epel-release -y                                                                                                                                                           0.0s
 => CACHED [ 3/12] RUN yum install fontconfig java-11-openjdk -y                                                                                                                                             0.0s
 => CACHED [ 4/12] RUN yum install wget -y                                                                                                                                                                   0.0s
 => CACHED [ 5/12] RUN wget --no-check-certificate -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo                                                                        0.0s
 => CACHED [ 6/12] RUN rpm -import http://pkg.jenkins.io/redhat-stable/jenkins.io.key                                                                                                                        0.0s
 => CACHED [ 7/12] RUN wget --no-check-certificate https://get.jenkins.io/war-stable/2.375.2/jenkins.war -P /usr/lib/jenkins                                                                                 0.0s
 => [ 8/12] RUN wget https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.12.9/jenkins-plugin-manager-2.12.9.jar -P /tmp                                                        3.6s
 => [ 9/12] COPY plugins.txt /root/.jenkins/plugins/                                                                                                                                                         0.0s 
 => ERROR [10/12] RUN java -jar /tmp/jenkins-plugin-manager-2.12.9.jar --war /usr/lib/jenkins/jenkins.war —-plugin-file /root/.jenkins/plugins/plugins.txt                                                   0.3s 
------                                                                                                                                                                                                            
 > [10/12] RUN java -jar /tmp/jenkins-plugin-manager-2.12.9.jar --war /usr/lib/jenkins/jenkins.war —-plugin-file /root/.jenkins/plugins/plugins.txt:                                                              
#14 0.266  --available-updates                         : Show available plugin updates for the requested plugins (default: false)
#14 0.266  --clean-download-directory                  : If sets, cleans the plugin download directory before plugin installation. Otherwise the tool performs
#14 0.266                                                plugin download and reports compatibility issues, if any. (default: false)
#14 0.266  --credentials <CREDENTIALS,CREDENTIALS,...> : Comma-separated list of credentials in format '<host>[:port]:<username>:<password>'. The password must
#14 0.266                                                not contain space or ','
#14 0.266  --jenkins-experimental-update-center URL    : Sets experimental update center; will override JENKINS_UC_EXPERIMENTAL environment variable. If not
#14 0.266                                                set via CLI option or environment variable, will default to https://updates.jenkins.io/experimental/upd
#14 0.266                                                ate-center.json
#14 0.266  --jenkins-incrementals-repo-mirror URL      : Set Maven mirror to be used to download plugins from the Incrementals repository, will override the
#14 0.266                                                JENKINS_INCREMENTALS_REPO_MIRROR environment variable. If not set via CLI option or environment
#14 0.266                                                variable, will default to https://repo.jenkins-ci.org/incrementals
#14 0.266  --jenkins-plugin-info URL                   : Sets the location of plugin information; will override JENKINS_PLUGIN_INFO environment variable. If
#14 0.266                                                not set via CLI option or environment variable, will default to
#14 0.266                                                https://updates.jenkins.io/plugin-versions.json
#14 0.266  --jenkins-update-center URL                 : Sets main update center; will override JENKINS_UC environment variable. If not set via CLI option or
#14 0.266                                                environment variable, will default to https://updates.jenkins.io/update-center.json
#14 0.266  --jenkins-version                           : Jenkins version to be used. If undefined, Plugin Manager will use alternative ways to retrieve the
#14 0.266                                                version, e.g. from WAR
#14 0.266  --latest VALUE                              : Set to true to download the latest version of all dependencies, even if the version(s) of the
#14 0.266                                                requested plugin(s) are not the latest. By default, plugin dependency versions will be determined by
#14 0.266                                                the update center metadata or plugin MANIFEST.MF (default: true)
#14 0.266  --latest-specified                          : Download latest transitive dependencies of any plugin that is requested to have the latest version. By
#14 0.266                                                default, plugin dependency versions will be determined by the update center metadata or plugin
#14 0.266                                                MANIFEST.MF (default: false)
#14 0.266  --list (-l)                                 : Lists all plugins currently installed and if given a list of plugins to install either via file or CLI
#14 0.266                                                option, all plugins that will be installed by the tool (default: false)
#14 0.266  --no-download                               : Avoid downloading plugins; can be used in combination with other options to see information about
#14 0.266                                                plugins and their dependencies (default: false)
#14 0.266  --output (-o) [STDOUT | YAML | TXT]         : Output format for available updates (default: STDOUT)
#14 0.266  --plugin-download-directory (-d) FILE       : Path to directory in which to install plugins; will override PLUGIN_DIR environment variable.
#14 0.266  --plugin-file (-f) FILE                     : Path to plugins.txt or plugins.yaml file
#14 0.266  --plugins (-p) STRING[]                     : List of plugins to install, separated by a space
#14 0.266  --skip-failed-plugins                       : Skip installing plugins that have failed to download. By default, if a single plugin is unavailable
#14 0.266                                                then all plugins fail to download and install. (default: false)
#14 0.266  --verbose                                   : Verbose logging (default: false)
#14 0.266  --version (-v)                              : View version and exit (default: false)
#14 0.266  --view-all-security-warnings                : Set to true to show all plugins that have security warnings (default: false)
#14 0.266  --view-security-warnings                    : Show if any security warnings exist for the requested plugins (default: false)
#14 0.266  --war (-w) VAL                              : Path to Jenkins war file (default: /usr/lib/jenkins/jenkins.war)
#14 0.266 No argument is allowed: ???-plugin-file
#14 0.266 Exception in thread "main" java.io.IOException: Failed to read command-line arguments
#14 0.266       at io.jenkins.tools.pluginmanager.cli.Main.main(Main.java:26)
#14 0.266 Caused by: org.kohsuke.args4j.CmdLineException: No argument is allowed: ???-plugin-file
#14 0.266       at org.kohsuke.args4j.CmdLineParser.parseArgument(CmdLineParser.java:509)
#14 0.266       at io.jenkins.tools.pluginmanager.cli.Main.main(Main.java:22)
------
executor failed running [/bin/sh -c java -jar /tmp/jenkins-plugin-manager-2.12.9.jar --war /usr/lib/jenkins/jenkins.war —-plugin-file /root/.jenkins/plugins/plugins.txt]: exit code: 1

接下来我可以尝试什么?

fkaflof6

fkaflof61#

你传递给“插件管理器”的标志似乎是导致问题的原因。您应该删除标志中的破折号并重新键入它们。此问题可能是由从“媒体”复制和粘贴引起的。

java -jar /tmp/jenkins-plugin-manager-2.12.9.jar --war /usr/lib/jenkins/jenkins.war --plugin-file /root/.jenkins/plugins/plugins.txt

相关问题