【问题标题】:Teamcity agent can't upload to artifactory using powershellTeamcity 代理无法使用 powershell 上传到工件
【发布时间】:2018-03-29 21:10:32
【问题描述】:

我正在尝试使用 powershell 和 nant 从 teamcity 上传到 artifactory。我尝试了两种使用Invoke-WebRequest 的方法以及更新WebClient。 Webclient.UploadFile 像这样失败:

使用“3”个参数调用“UploadFile”的异常:“一个异常 在 WebClient 请求期间发生。”

虽然Invoke-WebRequest 像这样失败:

Invoke-WebRequest :底层连接已关闭:一个 发送时发生意外错误。

如果我从那台机器手动运行它们中的任何一个,它都可以工作。如果它像这样以 teamcity 代理服务用户的身份启动 powershell

Start powershell -Credential (Get-Credential)

然后手动运行代码,它可以工作。只有当 teamcity 真正尝试进行部署时,它才会每次都失败。我已经申请了

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

修复,我已经应用了

[System.Net.ServicePointManager]::CertificatePolicy = {$true}

修复,当我手动运行它时它总是可以工作,但当它通过 teamcity 运行时它永远不会工作。怎么回事?

【问题讨论】:

  • 失败后你在神器'request.log'中看到了什么?
  • @Ariel 手动调用时,Invoke-WebRequestWebClient 都会在管理 -> 系统日志中显示正常条目。当通过 teamcity 调用时,它们都不会创建任何条目。
  • Teamcity前面有代理吗?看起来是代理问题阻止了请求
  • @Ariel 不是我所知道的。如果是这样,我会认为当我从 teamcity 代理手动运行时调用会失败,对吧?

标签: powershell teamcity artifactory powershell-4.0 teamcity-9.0


【解决方案1】:

我最终使用了另一个项目中更大的脚本,该脚本使用 WebClient 尝试“校验和部署”,以查看工件是否已更改,然后再尝试使用来自此 answer 的代码进行实际部署。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-15
    • 2014-04-26
    • 1970-01-01
    • 2016-01-14
    相关资源
    最近更新 更多