安装Jenkins插件的Jenkins CLI-错误UnknownHostException

tpgth1q7  于 2023-10-17  发布在  Jenkins
关注(0)|答案(2)|浏览(243)

我尝试使用Jenkins CLI安装Jenkins插件,命令如下:

java -jar jenkins-cli.jar -s http://localhost:8080 -auth @cred install-plugin https://updates.jenkins.io/download/plugins/htmlpublisher/1.31/htmlpublisher.hpi

得到了错误

Installing a plugin from https://updates.jenkins.io/download/plugins/htmlpublisher/1.31/htmlpublisher.hpi

ERROR: Unexpected exception occurred while performing install-plugin command.
java.net.UnknownHostException: updates.jenkins.io
        at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:229)
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.base/java.net.Socket.connect(Socket.java:609)
        at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:305)
        at java.base/sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
        at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:182)
        at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:507)
        at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:602)
        at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266)
        at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:373)
        at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:207)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
        at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:193)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1592)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
        at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250)
        at java.base/java.net.URL.openStream(URL.java:1165)
        at org.apache.commons.io.FileUtils.copyURLToFile(FileUtils.java:1068)
        at hudson.cli.InstallPluginCommand.run(InstallPluginCommand.java:110)
        at hudson.cli.CLICommand.main(CLICommand.java:251)
        at hudson.cli.CLIAction$ServerSideImpl.run(CLIAction.java:299)
        at hudson.cli.CLIAction$1.lambda$opened$0(CLIAction.java:154)
        at java.base/java.lang.Thread.run(Thread.java:829)

我试过的:

Jenkins版本:简体中文(zh_cn)
感谢你的帮助。

wwwo4jvm

wwwo4jvm2#

我发现另一个解决方案是使用REST API来安装特定的Jenkins插件版本(降级/升级Jenkins插件版本)

curl -vu user:token -F "filename=plugin-name" -F "pluginUrl=https://updates.jenkins.io/download/plugins/plugin-name/plugin-version/plugin-name.hpi" http://jenkins-url/manage/pluginManager/uploadPlugin

例如:

curl -vu admin:11ba4f5453eed5ea3aa7d3c5307199e3e9 -F "filename=thinBackup" -F "pluginUrl=https://updates.jenkins.io/download/plugins/thinBackup/1.15/thinBackup.hpi" http://localhost:8080/manage/pluginManager/uploadPlugin

然后重新启动Jenkins x1c 0d1x
多田!结果

P/S:我想使用REST API,而不是使用GUI,因为与REST API,我们可以写一个自动化脚本安装插件版本列表列表按要求.

相关问题