Jenkins 从 1.6xx 升级到 2.xx (1.642.3 -> 2.32.2)

Jenkins upgrade from 1.6xx to 2.xx (1.642.3 -> 2.32.2)

我在进行必要的备份 (THIN) 或 $JENKINS_HOME 后将 Jenkins 升级到 2.32.3 版本(就地升级),Jenkins 现在已启动并且 运行。

Manage Jenkins > Manage Plugins 下,我看到以下红色错误:

Manage Jenkins

Correct
There are dependency errors loading some plugins:
Environment Injector Plugin v2.1.3
envinject-api v1.2 is missing. To fix, install v1.2 or later.

在尝试安装 Environment Inject Plugin 2.1.3 时,日志(在 download/install 期间)显示相同的错误:

Installing Plugins/Upgrades

Preparation 
Checking update center connectivity
Success
Environment Injector Plugin 
 Failure -
java.io.IOException: Failed to dynamically deploy this plugin
    at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:1895)
    at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1652)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:110)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Failed to install envinject plugin
    at hudson.PluginManager.dynamicLoad(PluginManager.java:873)
    at hudson.PluginManager.dynamicLoad(PluginManager.java:813)
    at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:1891)
    ... 5 more
Caused by: java.io.IOException: Environment Injector Plugin v2.1.3 failed to load.
 - envinject-api v1.2 is missing. To fix, install v1.2 or later.
    at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:621)
    at hudson.PluginManager.dynamicLoad(PluginManager.java:863)
    ... 7 more

我在哪里可以得到这个 envinject-api 1.2 插件?我应该去获取 Github 项目(克隆它)并构建 Maven 项目并将 hpi 文件放在 $JENKINS_HOME/plugins 文件夹下吗?

在可用插件选项卡下,我没有看到 select 给定版本的选项(只有 2.1.3 可用)。我也没有看到 envinject-api 1.2 插件,我可以 select。我的理解是,selecting Environment Inject 2.1.3 应该根据其 MANIFEST 文件免费自动获取所有依赖插件。

$ cat $JENKINS_HOME/plugins/envinject/META-INF/MANIFEST.MF
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: nenashev
Build-Jdk: 1.8.0_121
Extension-Name: envinject
Specification-Title: The Jenkins Plugins Parent POM Project
Implementation-Title: envinject
Implementation-Version: 2.1.3
Plugin-Class: org.jenkinsci.plugins.envinject.EnvInjectPlugin
Group-Id: org.jenkins-ci.plugins
Short-Name: envinject
Long-Name: Environment Injector Plugin
Url: https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin
Compatible-Since-Version: 2.0
Plugin-Version: 2.1.3
Hudson-Version: 1.625.3
Jenkins-Version: 1.625.3
Plugin-Dependencies: envinject-api:1.2,ivy:1.21;resolution:=optional,m
 atrix-project:1.7,script-security:1.22
Plugin-Developers: Gregory Boissinot:gbois:gregory.boissinot@gmail.com
 ,Oleg Nenashev:oleg_nenashev:o.v.nenashev@gmail.com,Manuel Recena:rec
 ena:recena@gmail.com

出于某种原因,Jenkins 插件(未根据清单文件下载依赖插件)。

由于 envinject-api 插件未在 AVAILABLE 插件选项卡中列出(在 Manage Jenkins > Manage Plugins 部分),我不得不手动下载 .hpi /.jpi文件直接从下面下载插件 URL然后我把文件放在$JENKINS_HOME/plugins文件夹里。

https://updates.jenkins-ci.org/download/plugins/

wget https://updates.jenkins-ci.org/download/plugins/envinject-api/1.2/envinject-api.hpi

重新启动 Jenkins sudo service jenkins restart(或您设置的任何其他方式),这个问题在 Jenkins GUI 和 tail -f /var/log/jenkins/jenkins.log

中都消失了

PS:不要随意 select 任何插件或其依赖插件的最新版本。它可能无法工作并破坏更多其他插件,因为它取决于您当前的 Jenkins 版本。

为 Juseppe 找到了这个 link,不确定它的相关性如何,但看起来很有趣:https://github.com/yandex-qatools/juseppe