我试图改进Azure Data Factory管道的部署 . 换句话说,我计划仅将最近修改的管道或最近添加的管道部署到Azure门户中的ADF . 目前,我在CD管道中使用powershell任务来部署所有管道 . 如何使用时间戳获取最近修改的管道?任何建议都会有帮助 . :)
您可以使用REST API获取更改的文件 .
简单的powershell脚本:
Param( [string]$collection, [string]$project, [string]$repository, [string]$commit, [string]$token ) $u="$($collection)$($project)/_apis/git/repositories/$repository/commits/$commit/changes" Write-Output $u $changedFiles=New-Object System.Collections.ArrayList $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f "",$token))) $result=Invoke-RestMethod -Method Get -Uri $u -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -ContentType "application/json" Foreach($c in $result.changes) { If($c.item.isFolder -ne 'true') { Write-Output $c.item.path $changedFiles.Add(($c.item.path)) } }
参数(选中允许脚本在构建/发布定义中访问OAuth令牌选项):
-collection $(System.TeamFoundationCollectionUri) -project $(System.TeamProject) -repository $(Build.Repository.Name) -commit $(Build.SourceVersion) -token $(System.AccessToken)
如果您想构建所有文件,但只推送/发布要部署的已修改文件,那就可以了 .
您可以使用PowerShell任务获取 $(Build.SourcesDirectory) 中的最后一个提交ID(sha-1值),然后使用 git show <commit id> 查找提交中更改的文件,然后将这些文件复制到 $(build.artifactstagingdirectory) . 最后将这些文件发布到服务器 .
$(Build.SourcesDirectory)
git show <commit id>
$(build.artifactstagingdirectory)
2 回答
您可以使用REST API获取更改的文件 .
简单的powershell脚本:
参数(选中允许脚本在构建/发布定义中访问OAuth令牌选项):
如果您想构建所有文件,但只推送/发布要部署的已修改文件,那就可以了 .
您可以使用PowerShell任务获取
$(Build.SourcesDirectory)
中的最后一个提交ID(sha-1值),然后使用git show <commit id>
查找提交中更改的文件,然后将这些文件复制到$(build.artifactstagingdirectory)
. 最后将这些文件发布到服务器 .