C# Bitbucket管道.net部署

C# Bitbucket管道.net部署,c#,.net,mono,bitbucket,bitbucket-pipelines,C#,.net,Mono,Bitbucket,Bitbucket Pipelines,我正在尝试使用bitbucket的新工具管道。我有多个要构建和下载的.NET控制台应用程序(不是核心应用程序)。我发现这说明我可以使用mono来构建我的项目。我使用这个.yml文件来构建它 image: mono pipelines: default: - step: script: - nuget restore - MONO_IOMAP=case xbuild /t:Build /p:Configuration="

我正在尝试使用bitbucket的新工具管道。我有多个要构建和下载的.NET控制台应用程序(不是核心应用程序)。我发现这说明我可以使用mono来构建我的项目。我使用这个.yml文件来构建它

image: mono

pipelines:
  default:
    - step:
        script:
          - nuget restore
          - MONO_IOMAP=case xbuild /t:Build /p:Configuration="Release" /p:Platform="Any CPU" Solution.sln
构建成功,但现在我不得不下载我的应用程序(带有所有DLL的exe)。我发现我可以使用bitbucket下载。但是如何下载我的部署文件夹呢?我发现我可以压缩一些文件,然后将其放入bitbucket下载。但是我如何使用mono,如何压缩整个文件夹,然后下载它呢?我不介意使用其他类似mono的东西。

mono
debian:wheezy
,在YML文件的脚本部分运行的任何linux命令都可以帮助您在BitBucket管道拉下容器之前提取文件。最后有一个POST命令,用于将工件部署到Bitbucket中的下载

curl -v -u $BB_ACCESS -X POST https://api.bitbucket.org/2.0/repositories/$BITBUCKET_REPO_OWNER/$BITBUCKET_REPO_SLUG/downloads/ -F files=@aqua_lambda.zip
它为您进一步解释了环境变量
$BB_ACCESS


您需要找到mono编译到的文件路径,并调整示例代码以推送到Bitbucket下载,或者这也是一个不错的选择。

这个答案有点晚了

首先,使用msbuild代替xbuild,因为xbuild已被弃用

现在,您想要的是一个成功的构建,以及将发布推到bitbucket下载

1.为存储库所有者创建应用程序密码 以存储库所有者(也是将上载文件的用户)身份登录Bitbucket,然后转到Bitbucket设置>应用程序密码

使用写入权限创建一个新的应用程序密码,并记录弹出的生成密码。密码的名称仅供参考,因此请使用“管道”或任何其他您喜欢的名称

现在应该有两个值,这两个值将用于下一步

<username>: Bitbucket username of the repository owner (and also the user who will upload the artifacts)
<password>: App password as generated by bitbucket
管道bash可能没有安装zip。要安装zip,请在上述命令之前向管道中添加以下行:

- apt-get update
- apt-get -y install zip
现在,最后添加使用Bitbucket REST API的curl命令:

- curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"bin/Release.zip"
如果愿意,您可以从bin dir中删除不需要的release zip文件,因为zip现在已经在Bitbucket下载中:

- rm -f bin/Release.zip
以下是完整的pipeline.yml:

image: mono

pipelines:
  default:
    - step:
        script:
          - nuget restore
          - MONO_IOMAP=case msbuild /p:Configuration="Release" /p:Platform="AnyCPU" Solution.sln
          - apt-get update
          - apt-get -y install zip
          - zip -r bin/Release.zip bin/Release/
          - curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"bin/Release.zip"
          - rm -f bin/Release.zip
请注意,您的发布目录可能与上面的示例不同

image: mono

pipelines:
  default:
    - step:
        script:
          - nuget restore
          - MONO_IOMAP=case msbuild /p:Configuration="Release" /p:Platform="AnyCPU" Solution.sln
          - apt-get update
          - apt-get -y install zip
          - zip -r bin/Release.zip bin/Release/
          - curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"bin/Release.zip"
          - rm -f bin/Release.zip