【问题标题】:Teamcity - generate artifact from PowershellTeamcity - 从 Powershell 生成工件
【发布时间】:2016-04-26 12:20:36
【问题描述】:

我正在使用 Powershell 构建步骤并希望生成一个文件并将其包含在工件中。这是我尝试过的,但没有出现:

param(
[parameter(Mandatory=$true)] [string]$controller
)
Write-Output "Controller: $controller"

$testsettingsXML = @"
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="Remote" id="36b029f0-1e34-4c17-b7b1-3e6a0284a08e" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Description>These are default test settings for a local test run.</Description>
  <RemoteController name="$controller" />
  <Execution location="Remote">
    <TestTypeSpecific>
      <UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
        <AssemblyResolution>
          <TestDirectory useLoadContext="true" />
        </AssemblyResolution>
      </UnitTestRunConfig>
    </TestTypeSpecific>
    <AgentRule name="AllAgentsDefaultRole">
    </AgentRule>
  </Execution>
  <Properties />
</TestSettings>
"@

#write the testsettings file out to disk.
$testsettingsXML | Out-File -FilePath "./remotehack.testsettings" -Encoding utf8

我在 metarunner 中做了类似的事情,效果很好。为什么不在这里?

【问题讨论】:

  • 如果没有设置位置,ps 脚本是否可能不会在您期望的位置执行。如果您将其设置为 -FilePath 的完整路径以进行测试运行并查看该文件是否会出现?
  • 您是否尝试在同一用户下的同一代理上手动调用此脚本?运行成功了吗?

标签: powershell teamcity


【解决方案1】:

问题有三方面。

  1. Powershell 的最后一行应该是这样的:

    $testsettingsXML | Out-File -FilePath "remotehack.testsettings" -Encoding utf8

  2. 我没有包含 remotehack.testsettings/remotehack.testsettings 作为工件依赖项

  3. 我没有在常规设置下包含工件路径“remotehack.testsettings”。

一些新手错误。

【讨论】:

    猜你喜欢
    • 2015-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多