Jenkins 代理后-代理 URL 中的非法字符

Jenkins 代理后-代理 URL 中的非法字符

我在公司代理后面运行 Jenkins。我的代理密码包含特殊字符,例如“P@ssw0rd”。

构建管道时出现以下异常

 Started by user unknown or anonymous
java.net.URISyntaxException: Illegal character in hostname at index 38: http://user:P%40ssw0rd@internet_proxy.abc.com:80
    at java.net.URI$Parser.fail(URI.java:2848)
    at java.net.URI$Parser.parseHostname(URI.java:3387)
    at java.net.URI$Parser.parseServer(URI.java:3236)
    at java.net.URI$Parser.parseAuthority(URI.java:3155)
    at java.net.URI$Parser.parseHierarchical(URI.java:3097)
    at java.net.URI$Parser.parse(URI.java:3053)
    at java.net.URI.<init>(URI.java:673)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1751)
Caused: hudson.plugins.git.GitException: Failed to create http proxy uri
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1755)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442)
    at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:351)
    at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:198)
    at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:174)
    at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:108)
    at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:67)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:293)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE

我使用测试 URL 验证代理时得到了肯定的响应。

代理 URL 片段 -

http://user:P%40ssw0rd@internet_proxy.abc.com:80

答案1

任何“特殊”字符都需要进行百分比转义,特别 @,因为这是 URL 的密码和主机名部分之间的分隔符。

答案2

尝试在密码周围加上引号,或者在特殊字符前使用 \(反斜杠。

相关内容