简体   繁体   English

如何通过发布管道 CMD 任务自动将文件上传到 Azure DevOps 存储库

[英]How to Automatically upload a file to Azure DevOps repository through a release pipeline CMD task

I have created a release pipeline in Azure devops to generate the.dacpac file using CMD task in release pipeline.我在 Azure devops 中创建了一个发布管道,以使用发布管道中的 CMD 任务生成 .dacpac 文件。 The.dacpac file is getting generated successfully when I am giving \tf: path as $(Agent.HomeDirectory).当我将 \tf: 路径作为 $(Agent.HomeDirectory) 时,.dacpac 文件正在成功生成。 I want to give path of the folder in my repository where I would like to save the.dacpac file.我想在我的存储库中提供要保存 .dacpac 文件的文件夹的路径。

Below is the command which I tried to store the file on (Agent.HomeDirectory) and it runs fine.下面是我尝试将文件存储在(Agent.HomeDirectory)上的命令,它运行良好。

C:\Program Files (x86)\Microsoft SQL Server\150\DAC\bin>sqlpackages.exe /Action:Extract /ssn:tcp:,1433 /sdn: /su: /sp: /tf:$(Agnet.HomeDirectory)/test.dacpac /p:Storage=File C:\Program Files (x86)\Microsoft SQL Server\150\DAC\bin>sqlpackages.exe /Action:Extract /ssn:tcp:,1433 /sdn: /su: /sp: /tf:$(Agnet.HomeDirectory )/test.dacpac /p:Storage=File

Please guide me how we can store the file to repository folder from command line.请指导我如何从命令行将文件存储到存储库文件夹。

Thanks, Sachin谢谢,萨钦

Please refer to the following steps:请参考以下步骤:

  1. I created a release pipeline and added this repo: testproject, branch: test我创建了一个发布管道并添加了这个 repo:testproject,branch:test 在此处输入图像描述

  2. Add CMD task, the script is as follows:添加CMD任务,脚本如下:

    cd D:\a\r1\a_testproject cd D:\a\r1\a_testproject

    cd.光盘。 > 001.txt // I create a test txt here. > 001.txt // 我在这里创建一个测试 txt。 Please copy the file you need to the path.请将您需要的文件复制到该路径。 Or you can to use git to clone a repo in the path you want.或者您可以使用 git 在您想要的路径中克隆一个 repo。

    git config --global user.email "xxxx@mail.com" git 配置 --global user.email "xxxx@mail.com"

    git config --global user.name "xxxx" git 配置 --global user.name "xxxx"

    git status git 状态

    git add -A git 添加-A

    git status git 状态

    git commit -m "Latest updated" git show-ref git commit -m "最新更新" git show-ref

    git push -u origin HEAD:test //if the push step show the error: src refspec xxxx does not match any. git push -u origin HEAD:test //如果推送步骤显示错误:src refspec xxxx 不匹配。 please check the log and choose a rignt head请检查日志并选择正确的头

在此处输入图像描述

  1. Allow scripts to access the OAuth token允许脚本访问 OAuth 令牌在此处输入图像描述

  2. set permission of the account {projectname} Build Service (orgname)设置帐户{projectname} Build Service (orgname)的权限在此处输入图像描述

For more info,please refer Copy file from CI Pipeline to Azure Devops Repository and How to add/update files in git repository from Azure DevOps Pipeline Dynamics 365 CE .有关更多信息,请参阅将文件从 CI 管道复制到 Azure Devops 存储库以及如何在 git 存储库中添加/更新文件从 Z3A580F142203677F1F0BC30898F63F53 动态开发管道

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

相关问题 在 Azure DevOps Release Pipeline 中自动创建标签 - Automatically create a Label in Azure DevOps Release Pipeline 在 azure devops 中选择发布管道中的任务 - selection of task in release pipeline in azure devops Azure DevOps - 恢复数据库的管道发布任务 - Azure DevOps - Pipeline Release Task to Restore Database 如何在发布管道中的 Azure DevOps 中输出 terraform 输出文件 - How to output terraform output file in Azure DevOps in release pipeline Azure DevOps 发布管道 - Azure Devops Release Pipeline Azure DevOps 管道 CMD 任务 [错误] 访问被拒绝 - Azure DevOps Pipeline CMD task [error]Access is denied 无法在 Azure DevOps 发布管道任务中更改服务连接 - Can't change service connection in Azure DevOps release pipeline task 如何将多个 json 文件导入/上传到 Azure Devops Pipeline Release and Builds? - How to import/upload multiple json files to Azure Devops Pipeline Release and Builds? How to Use Powershellscript in Azure classic Release pipeline - 脚本文件存储在Azure Devops Secure File - How to Use Powershellscript in Azure classic Release pipeline - script file stored in Azure Devops Secure File Azure Devops Release Pipeline - 将单个文件部署到Azure App Service - Azure Devops Release Pipeline - Deploy single file to Azure App Service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM