gitazure-devopscontinuous-integrationcontinuous-deploymentazure-pipelines-release-pipeline

How to build an artifact from a given branch in azure pipelines?


I am super new at this. I want to build an artifact based on a branch in my azure devops repository i.e An artifact from development branch and use that artifact to release to my dev environment in release pipeline. I am using this to only move around code for my databricks workspaces. Any help or direction is appreciated. Thank you

trigger:
  branches:
    include:
      - development

stages:
- stage: build
  displayName: Build
  variables:
    databricksSourceFolder: $(Build.SourcesDirectory)/$(code_build_path)
  jobs:
  - job: builddb
    displayName: Build Databricks
    steps:
    - publish: $(databricksSourceFolder)
      artifact: Databricks

Tried this but this still builds from the main branch and not development


Solution

  • To run build for the development branch, you need to check with the following things:

    1. As you have configured in the YAML file of the build pipeline, ensure the branch filters on the CI trigger include the development branch.

      trigger:
        branches:
          include:
          - development
      
    2. Ensure the YAML file with above configurations is existing in the development branch.

    3. After above steps, when new commits pushed to the development branch, a new run of the build pipeline will be triggered. This new run will use the new commits on the development branch to build.

    4. If you manually trigger the build pipeline, on the pop-up window, you can select which git ref (branch, tag or commit) the pipeline will run for. Then the new run will use the latest commit on the selected ref to build.

      enter image description here

    5. After the build task (such as DotNetCoreCLI, VSBuild, etc..), don't forget to use the PublishPipelineArtifact task to publish the build artifacts so that the subsequent release pipeline can get the artifacts to release.


    In the classic release pipeline, you can configure like as below:

    1. Add the build pipeline as the Source artifact.

      enter image description here

    2. Set the CD trigger (Continuous deployment trigger). If you want the release pipeline can be triggered only when the build runs for the development branch, you can set the branch filters to only include the development branch.

      enter image description here

    3. Add the stage to release the artifact to the dev environment.

      enter image description here

    4. On the Pre-deployment conditions settings of the stage, you can add the Artifact filters to let the stage be triggered only when the build artifacts are from the specified development branch.

      enter image description here