使用PS在appveyor中使用twine上传

时间:2017-06-19 13:50:43

标签: python pypi appveyor

在AppVeyor上的部署脚本中,我使用ps: >-命令进行部署,具体取决于repo分支:

- ps: >-
    If ($env:APPVEYOR_REPO_BRANCH -eq 'devel') { 
        echo not deploying on devel # twine upload --skip-existing -r test dist/*
    }
    ElseIf ($env:APPVEYOR_REPO_BRANCH -eq 'deploy') {  
        twine upload --skip-existing dist/*
    }
    Else {
        echo not deploying on other branches
    }

这会在AppVeyor构建上创建一条错误消息,如下所示:

twine : 
At line:2 char:5
+     twine upload --skip-existing dist/*
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

构建显示为失败。奇怪的是,这些包被上传到pypi并可供下载。因此该命令实际上运行良好,但由于此异常,构建显示为失败。如果只有错误信息会提供更多信息...

使用更简单的脚本进行另一次运行,并在AppVeyor(https://ci.appveyor.com/project/mzwiessele/gpy/build/1.0.361/job/baimi4og179tk3p8)上看到完整输出

if ($env:APPVEYOR_REPO_BRANCH -eq 'deploy') {  
    twine upload --skip-existing dist/*
} else {
    echo not deploying on other branches
}
twine : 
At line:2 char:5
+     twine upload --skip-existing dist/*
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

  0%|          | 0.00/1.21M [00:00<?, ?bytes/s]
  1%|          | 8.19K/1.21M [00:00<00:21, 56.1Kbytes/s]
  8%|8         | 98.3K/1.21M [00:00<00:14, 77.6Kbytes/s]
 33%|###3      | 401K/1.21M [00:00<00:07, 109Kbytes/s]  

  0%|          | 0.00/1.43M [00:00<?, ?bytes/s]

Uploading distributions to https://upload.pypi.org/legacy/
Uploading GPy-1.7.6-cp27-cp27m-win_amd64.whl
Uploading GPy-1.7.6.win-amd64-py2.7.exe
Command executed with exception: 

1 个答案:

答案 0 :(得分:1)

这是因为RemoteException将输出写入StdErr,并且PowerShell主机将任何输出到StdErr的内容视为const char*。尝试将该PS命令重写为批处理文件。