简体   繁体   English

是否可以让 Azure DevOps Pipeline 将工件发布到辅助 GIT 存储库?

[英]Is it possible to have an Azure DevOps Pipeline publish artifacts to a secondary GIT repository?

We are currently trying to automate builds of our legacy VB6 application in Azure DevOps.我们目前正在尝试在 Azure DevOps 中自动构建我们遗留的 VB6 应用程序。 One of the (many) idiosyncrasies of VB6 is that you need to put line numbers in your code in order for your exception messages to tell you on which line of code the exception occurred (welcome to 1998, it is the future). VB6 的(许多)特性之一是您需要在代码中输入行号,以便您的异常消息告诉您发生异常的代码行(欢迎来到 1998,这是未来)。 We have a tool that gets run as part of the build process that generates an intermediate set of source code with the line numbers which then gets built into binaries.我们有一个作为构建过程的一部分运行的工具,它生成一组中间源代码,其中包含行号,然后构建到二进制文件中。 Keeping the line numbered code around is important for debugging purposes, what we would like to do is commit the line numbered code to a secondary GIT repository and then tag the commit with the build number.保留行号代码对于调试目的很重要,我们想做的是将行号代码提交到辅助 GIT 存储库,然后用内部版本号标记提交。 How do I go about publishing my build artifacts to a git repository?我如何 go 关于将我的构建工件发布到 git 存储库?

How do I go about publishing my build artifacts to a git repository?我如何 go 关于将我的构建工件发布到 git 存储库?

You can add a CMD / PS task at the end of your pipeline to run git-related commands to clone the repo locally, do changes and commit,tag commit and then push the changes to remote repo.您可以在管道末尾添加CMD / PS任务以运行与 git 相关的命令以在本地克隆存储库、进行更改和提交、标记提交,然后将更改推送到远程存储库。

1.If the second git repo is a github repo, you can try script below in CMD task: 1.如果第二个 git repo 是 github repo,您可以在 CMD 任务中尝试以下脚本:

git clone https://{userName}:{userPassword}@github.com/xxx/{RepoName}.git

git checkout master

git config --global user.email MyEmail@outlook.com

git config --global user.name MyName

copy "Test.txt" {RepoName}

cd {RepoName}

git add .

git commit -m "Add line numbered code."

git tag $(Build.BuildNumber)

git push https://{userName}:{userPassword}@github.com/xxx/{RepoName}.git master tag $(Build.BuildNumber)

You should replace the {userName},{userPassword} and {RepoName} with your own info.您应该将{userName},{userPassword} and {RepoName}替换为您自己的信息。 For step5, you can use either copy or xcopy command to copy the file(including.zip file)/files to the folder whose name is {RepoName} (Your second repo will be downloaded into this folder).对于第 5 步,您可以使用copyxcopy命令将文件(包括 .zip 文件)/文件复制到名称为{RepoName}的文件夹中(您的第二个 repo 将下载到此文件夹中)。

2.If the second repo is an Azure Devops git Repo, you also need to make sure your current ProjectName Build Service has the permission to create tag (Project Settings=>Repositories=>Permissions): 2.如果第二个repo是Azure Devops git Repo,你还需要确保你当前的ProjectName Build Service有创建标签的权限(Project Settings=>Repositories=>Permissions):

在此处输入图像描述

And to do clone/push with Azure Repo, PAT with limited permission is more recommended.并使用 Azure Repo 进行克隆/推送,更推荐使用有限权限的PAT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM