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?

diogo.abdalla
  • 161
  • 1
  • 5

1 Answers1

0

A simple solution could be to just use a bash or PowerShell script task in the deployment stage that performs a git pull/checkout of your code in the target folder on the VM.

You should however be careful about what is pulled and checked out of git on the deployment target. By using the variable Release.Artifacts.{alias}.SourceVersion as specified here you can make sure you are checking out a commit that has been tested in a previous stage of the pipeline