> For the complete documentation index, see [llms.txt](https://jadelab.gitbook.io/jadegit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jadelab.gitbook.io/jadegit/0.18.0/admin/jadegit-builds/example.md).

# Example

This page shows one way to implement an internal superproject that references a public JadeGit source repository, with pipelines to manage updates and produce internal builds in Azure DevOps.

## Repository Structure

The internal repository is structured as a superproject, with the JadeGit source included as a Git submodule:

```
.gitmodules
deps/
  jadegit
pipelines/
  build.yml
  update.yml
```

The submodule references a public JadeGit repository and pins the commit used for internal builds.

```toml
[submodule "jadegit"]
	path = deps/jadegit
	url = https://gitlab.com/jadelab/jadegit.git
```

## Update Pipeline

The update pipeline moves the submodule reference to a specific branch, tag, or commit. This can be run on a feature branch and validated through a pull request before merging.

```yaml
trigger: none

parameters:
- name: ref
  displayName: 'JadeGit Branch/tag'
  type: string
  default: main

steps:
- checkout: self
  persistCredentials: true
  submodules: true

- powershell: |
    git fetch --depth=1 --tags origin +refs/heads/*:refs/heads/*
    git switch --detach ${{ parameters.ref }}
  workingDirectory: deps/jadegit
  displayName: 'Update Submodule'
  
- powershell: |
    git config user.name "$(Build.RequestedFor)"
    git config user.email "$(Build.RequestedForEmail)"
    git add deps/jadegit
    git commit -m "Update jadegit (${{ parameters.ref }})"
  displayName: 'Commit Update'

- powershell: 'git push origin HEAD:$(Build.SourceBranch)'
  displayName: 'Push Update'
```

## Build Pipeline

The build pipeline compiles JadeGit for the required platform versions and publishes the resulting binaries.

```yaml
trigger:
- main

parameters:
- name: platforms
  type: object
  displayName: Jade Platforms
  default:
  - name: Jade 2022 SP4 (ANSI)
    version: 22.0.05
    charset: ansi
  - name: Jade 2025 R1 (ANSI)
    version: 25.0.01
    charset: ansi

jobs:
- job: Prepare
  pool:
    vmImage: 'windows-2022'
  steps:
  - checkout: self
    fetchDepth: 100
    submodules: recursive

  - powershell: |
      $version = git describe --tags --match "v[0-9]*"
      $baseVersion = [regex]::match($version, '^v(\d*\.\d*).*').Groups[1].Value
      Write-Host "##vso[task.setvariable variable=version;isoutput=true]$version"
      Write-Host "##vso[task.setvariable variable=baseVersion;isoutput=true]$baseVersion"
    displayName: 'Get Version'
    name: GetVersion
    workingDirectory: 'deps/jadegit'

- job: Build
  dependsOn: Prepare
  pool:
    vmImage: 'windows-2022'
  timeoutInMinutes: 0
  variables:
    buildConfig: 'RelWithDebInfo'
    version: $[dependencies.Prepare.outputs['GetVersion.version']]
    baseVersion: $[dependencies.Prepare.outputs['GetVersion.baseVersion']]
    buildNumber: $[counter(variables['baseVersion'],0)]
  strategy:
    matrix:
      Console:
        package: 'console'
        packageDescription: 'Console Utility'
      ${{ each platform in parameters.platforms }}:
        Dev ${{ platform.name }}:
          package: 'dev-${{ platform.version }}-${{ platform.charset }}'
          packageDescription: ${{ platform.name }}
          jade.version: ${{ platform.version }}
          jade.charset: ${{ platform.charset }}

  steps:
  - checkout: self
    fetchDepth: 100
    submodules: recursive

  - powershell: 'cmake -S deps/jadegit -B build -A x64 -D CMAKE_INSTALL_PREFIX:PATH=.. -DUSE_JADE="OFF"'
    condition: and(succeeded(), eq(variables['jade.version'], ''))
    displayName: 'Configure'

  - powershell: 'cmake -S deps/jadegit -B build -A x64 -D CMAKE_INSTALL_PREFIX:PATH=.. -DUSE_JADE="ON" -DJADE_VERSION="$(jade.version)" -DUNICODE="$(if ("$(jade.charset)" -eq "unicode") {"ON"} else {"OFF"})"'
    condition: and(succeeded(), ne(variables['jade.version'], ''))
    displayName: 'Configure'

  - task: CMake@1
    displayName: 'Build'
    inputs:
      cmakeArgs: '--build $(Build.SourcesDirectory)/build --config "$(buildConfig)" --target install'

  - powershell: |
      Write-Host "##vso[task.setvariable variable=testRunTitle]$('$(Agent.JobName)' -replace 'Build ', '')"
      bin\jadegit --version
      bin\jadegit_test -r junit -o test_results.xml
    continueOnError: true
    displayName: 'Run Tests'
    workingDirectory: $(Build.SourcesDirectory)\build

  - task: PublishTestResults@2
    condition: succeeded()
    displayName: 'Publish Test Results'
    inputs:
      failTaskOnFailedTests: true
      failTaskOnMissingResultsFile: true
      searchFolder: $(Build.SourcesDirectory)\build
      testResultsFormat: 'JUnit'
      testResultsFiles: 'test_results.xml'
      testRunTitle: $(testRunTitle)

  - task: PublishSymbols@2
    displayName: 'Publish Symbols'
    inputs:
      symbolsFolder: '$(Build.SourcesDirectory)'
      indexSources: true
      publishSymbols: true
      symbolServerType: TeamServices
      symbolsProduct: 'jadegit-$(package)'
      symbolsVersion: '$(version)'

  - task: CopyFiles@2
    displayName: 'Copy Files To Publish'
    inputs:
      sourceFolder: '$(Build.SourcesDirectory)/bin'
      contents: '@(jadegit)*.@(dll|exe)'
      targetFolder: '$(Build.ArtifactStagingDirectory)'

  - task: UniversalPackages@0
    displayName: 'Publish Universal Package'
    inputs:
      command: publish
      vstsFeedPublish: '$(System.TeamProject)/Jade'
      vstsFeedPackagePublish: jadegit-$(package)
      versionOption: custom
      versionPublish: $(baseVersion).$(buildNumber)
      packagePublishDescription: 'JadeGit $(version) - $(packageDescription)'
```
