0

Im using a Azure VM for the first time (linux, Ubuntu 18) and Ive been tasked with setting a pipeline/release for continuous development for a simple website

Its supposed to work like this: when master branch is commited to Azure, automatically run the pipeline and release to deploy it to a directory in the VM (theres is no build involved, is a simple Wordpress site)

I managed to get it working like this:

  1. Ive set a pipeline that just gets the code from the git and copies it to $(Build.ArtifactStagingDirectory) (using a Copy Files task)
  2. than it publishes it as an artifact (using Publish Artifact task)

Then a release pipeline that does the following:

  1. copies the artifact files to the directory (using Copy Files task again)

It is working but it doenst seems good. Theres some obvious problems:

  1. is slow: it will copy all files every time, not just what was changed
  2. if I delete a file, it wont be deleted on the deploy directory

So what I want is some way to sync the git commit with the site directory, overwriting only changed files and deleting any deleted files, ignoring files and directories on .git-ignore etc

Seems simple (I know how to do it with git hooks) but I just cant find a way to do it in Azure DevOps

Is it possible? Can anyone give me a direction?

LeGEC
  • 46,477
  • 5
  • 57
  • 104
diogo.abdalla
  • 628
  • 1
  • 8
  • 18

1 Answers1

1

Azure release pipeline: synce files with commit

Azure devops build/release does not support build/release only changed files since only build/release changed files not always meaningful and can't achieve what the project intend to release.

But we could compare each time upload/publish files -> compare with the new committed information -> publish only changed files:

Inline powershell:

cd $(System.DefaultWorkingDirectory)

get-childitem $(System.DefaultWorkingDirectory) -recurse | Foreach { 
        $lastupdatetime=$_.LastWriteTime; 
        $nowtime=get-date; 
        if(($nowtime - $lastupdatetime).totalhours -le 48) { 
          Write-Host $_.fullname 
        } 
        else{ 
          remove-item $_.fullname -Recurse -Force 
        } 
      }

Above powershell scripts will list all files that have been modified in the past 48 hours.

You could check this thread for some more details.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Leo Liu
  • 71,098
  • 10
  • 114
  • 135