生成最后提交的SQL脚本VSTS [英] Build last commited SQL Script VSTS
问题描述
我是VSTS的新手,我想知道如何始终仅构建最新的提交的SQL脚本.
I'm new to VSTS and I want to know how to always build only the latest committed SQL Script.
示例:我从存储库中提交了example.sql
,VSTS Build只需要压缩"example.sql"并发布工件即可发布.
Example: I committed example.sql
from my repository, the VSTS Build needs to get only the "example.sql" zip it and publish the artifact to get ready to release.
我该怎么办?
推荐答案
VSTS 构建当前工作树的所有现有文件/脚本(仓库的指定分支).
VSTS build all the existing files/scripts of the current working tree (specified branch of the repo).
如果要压缩最新的更改文件并将其作为工件发布,则可以添加PowerShell任务(对于Linux和Mac,可以改用Shell脚本任务)作为助手.检测更改/添加的详细步骤如下:
If you want to zip and publish the latest changed files as artifacts, you can add a PowerShell task (for linux and mac, you can use Shell script task instead) for assistant. Detail steps to detect the changed/added as below:
1.使用PowerShell任务获取更改/添加的文件,并将文件从$(Build.SourcesDirectory)
复制到另一个目录(例如$(Build.ArtifactStagingDirectory)\files
). Powershell脚本如下:
1. Use PowerShell task to get changed/added file(s) and copy the file(s) from $(Build.SourcesDirectory)
to another directory (such as $(Build.ArtifactStagingDirectory)\files
). The Powershell script as below:
$files=$(git diff HEAD HEAD~ --name-only)
echo $files
$temp=$files -split ' '
$count=$temp.Length
echo "Total changed $count files"
New-Item -ItemType directory -Path $(Build.ArtifactStagingDirectory)\files
For ($i=0; $i -lt $temp.Length; $i++)
{
$name=$temp[$i]
echo "this is $name file"
if (Test-Path "$(Build.SourcesDirectory)\$name")
{
Copy-Item $(Build.SourcesDirectory)\$name $(Build.ArtifactStagingDirectory)\files
}
}
2.使用存档文件任务来压缩更改的文件.,例如从$(Build.ArtifactStagingDirectory)\files
目录到$(Build.ArtifactStagingDirectory)\pack\$(Build.BuildId).zip
.
3.使用发布构建工件任务从$(Build.ArtifactStagingDirectory)\pack
目录发布压缩文件.
3. Use Publish Build Artifacts task to publish the zipped file from $(Build.ArtifactStagingDirectory)\pack
directory.
这篇关于生成最后提交的SQL脚本VSTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!