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:

    1. 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.

    2. set result variable value based on if there metadata updated or not.

      if data updated, change result variable value 1:

      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 result 1. 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 result variable 1, can express:

    and(succeeded(), eq(variables['result'], '1')) 

now if result value 0, dacpac step skipped, result value 1, dacpack executed.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -