通过HTTPS下载XML

问题描述 投票:0回答:1

我正在尝试从Jenkins HTTPS服务器下载XML文件(Jenkins config.xml历史文件)。我在这里和其他地方搜索过,但仍然找不到让它工作的方法。

$url = "https://<server-path>/configOutput?type=xml&timestamp=2018-02-23_13-09-02"

$file = "d:\file.xml"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Ssl3
$wc = New-Object System.Net.WebClient
$wc.Credentials = Get-Credential
$wc.DownloadFile($url, $file)

提供凭据以提示我收到此错误:

Exception calling "DownloadFile" with "2" argument(s): "The underlying connection
was closed: An unexpected error occurred on a receive."
At D:\ps\jenkins-config\get_xml.ps1:7 char:1
+ $wc.DownloadFile($url,$file)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException
xml powershell https copy
1个回答
0
投票

我使用Invoke-WebRequest方法:

Invoke-WebRequest -Uri $url -ContentType 'application/xml' -OutFile $file -Credential $(Get-Credential) -Timeout 60

我见过JobConfigHistory插件的作业历史记录“configOutput”。我从来没有见过它来获取Jenkin的配置文件(JENKINS_HOME中的那个)。如果您正在尝试控制作业的配置,请仔细检查您的URL。

© www.soinside.com 2019 - 2024. All rights reserved.