build - Deploy dacpac through VSTS only if it's been modified since last deploy -
in deploy dacpac step in vsts, can set database run based on custom conditions. conditions examples based on vsts build information, , can't find documentation on using conditions connected azure subscription or dacpac metadata. in conditional page, have version variable seems might useful, can't find other information it.
basically, when dacpac step triggered, want check metadata against existing data, conditionally run build step, , update metadata. possible through vsts build step?
yes, possible. can add user defined variable (such variable result default value 0) in vsts build definition. , value 1 run dacpac step, value 0 skip step.
detail steps below:
add powershell task 2 operations before dacpac step:
check if there has new changes existing data.
if metadata stored in azure, can refer this way connect azure in powershell. if metadata stored in repository (such git repo) build with, can check update in repository.
set
resultvariable value based on if there metadata updated or not.if data updated, change
resultvariable value1:write-host ("##vso[task.setvariable variable=result]1")else, not change value (keep value
0)
since data managed in git vcs, can check if data update or not in git repo. if data changed, change variable
result1. detail powershell script below:$files=$(git diff head head~1 --name-only) echo "changed files below: $files" if ($files -contains 'filename') write-host ("##vso[task.setvariable variable=result]1")set conditions dacpac step:
in task, select custom conditions run task. if want run task when succeeding , variable
resultvariable1, can express:and(succeeded(), eq(variables['result'], '1'))
now if result value 0, dacpac step skipped, result value 1, dacpack executed.
Comments
Post a Comment