GXserver Azure - Synchronize to Git

Official Content
This documentation is valid for:

If you wish to track changes across your generated objects or Sources, you can add the following job definitions to synchronize them to a Git server.

In order to clone a repository and pull changes:

  - job: CloneOrPull
      - script: |
          IF EXIST "$(GIT_BRANCH)" (
            cd $(GIT_BRANCH)
            git checkout $(GIT_BRANCH)
            git pull
          ) ELSE (
            git clone https://$(GIT_USER):$(GIT_PASSWORD)@$(GIT_REPO) $(WORKING_DIR)\$(GIT_BRANCH)
        workingDirectory: $(WORKING_DIR)
        name: CloneOrPull

To push your changes to remote:

  - job: PushToGit
    dependsOn: CloneOrPull
      - script: >
          cd $(GIT_BRANCH)

          git checkout $(GIT_BRANCH)


          git add *
          git commit -m "Commit build $(Build.BuildNumber)"

          git push -u origin $(GIT_BRANCH)
        workingDirectory: $(WORKING_DIR)
        name: CommitPush


The following are specific variable definitions required for the task. See Initial Configuration for the generic variables required.

GIT_USER: string
Username of a Git account with permissions over the existing repository.

Password or Private Access Token associated with the Git Username. PAT is recommended; add parameter as Secret Variable. Using PAT requires full repository access permissions when generated.

GIT_REPO: string 
HTTPS connection repository URL. Said repository has to be previously initialized. We will be storing the tracked files here.
Example: “dev.azure.com/GeneXusDesa/GeneXusBuild/_git/GeneXusBuild”

GIT_BRANCH: string
Name of the branch for versioning. It has to be previously created.
Example: “main”