我正在尝试从Jenkins HTTPS服务器下载XML文件(Jenkins config.xml历史文件)。我在这里和其他地方搜索过,但仍然找不到让它工作的方法。
$url = "https://<server-path>/configOutput?type=xml×tamp=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
我使用Invoke-WebRequest
方法:
Invoke-WebRequest -Uri $url -ContentType 'application/xml' -OutFile $file -Credential $(Get-Credential) -Timeout 60
我见过JobConfigHistory插件的作业历史记录“configOutput”。我从来没有见过它来获取Jenkin的配置文件(JENKINS_HOME中的那个)。如果您正在尝试控制作业的配置,请仔细检查您的URL。