1,先建好source存储的Repos
2,然后创建Pipeline或release pipeline都可以,创建方式有所不同,但后边设定job的地方是相同的
(1)Pipeline创建点击New pipeline后要选择Use the classic editor to create a pipeline without YAML.
(2)release pipeline创建时,artifact的Source type要选Azure Repos Git
3,添加task,先安装PowerPlatform Build Tools,然后依次添加
(1)Power Platform Tool Installer
(2)Power Platform Export Solution
(3)Power Platform Unpack Solution
(4)Command Line Script
※Power Platform Pack Solution可以把 Unpack Solution 再打包回zip包,不做恢复时可以不用
4,细节的补充
(1)选中Allow scripts to access the OAuth token
(2)repos的security里把user的Contribute,Contribute to pull requests,Create branch,Create repository,Create tag这些权限都加上
(3)建立连接时推荐用service principal,如果要用用户密码的话,创建连接类型为generic
(4)Command Line Script代码如下,先CD到你的Repos下,不然执行可能会报错
cd $(System.DefaultWorkingDirectory)/_AJKPOCREPOS
cd
echo Commit Power Platform Solution
git config user.email "[email protected]"
git config user.name "Build Pipeline"
git checkout main
git pull origin
git add --all
git commit -m "Automatic solution commit"
git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" push origin main
(5)如果做其他环境导入的话,用Power Platform Import Solution 把导出的solution导入到其他环境就好
(6)使用releasepipelinge还可以做定期备份