Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predefined Build.SourceBranch variable not working #38

Open
ofir123 opened this issue Jun 11, 2021 · 2 comments
Open

Predefined Build.SourceBranch variable not working #38

ofir123 opened this issue Jun 11, 2021 · 2 comments
Labels
bug Something isn't working idle Inactive for 14 days P1 Some scenario broken but workaround exists

Comments

@ofir123
Copy link

ofir123 commented Jun 11, 2021

Hi,

We're trying to migrate from pr triggers in the azure-pipeline.yml to a GitHub Action trigger, using the following action:

  ...
  azure_pipeline:
    needs: [previous_action]
    runs-on: ubuntu-latest
    steps:
      - name: Azure Pipelines Action
        uses: Azure/pipelines@v1
        with:
          azure-devops-project-url: https://dev.azure.com/organization/project
          azure-pipeline-name: cogz-ci
          azure-devops-token: ${{ secrets.AZURE_DEVOPS_TOKEN }}

The trigger works great, but some of the build information is missing.

For example, our build name in the azure-pipeline.yml file is defined as follows:
name: cogz-ci-$(branchName)-$(Date:yyyyMMdd)$(Rev:.rr)
branchName is defined in a global template as:

  ${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
    branchName: $[ replace(replace(replace(variables['system.pullRequest.sourceBranch'], 'refs/heads/', ''), '\', '-'), '/', '-') ]
  ${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/') }}:
    branchName: $[ replace(replace(replace(variables['build.sourceBranch'], 'refs/heads/', ''), '\', '-'), '/', '-') ]

When running with the azure pipelines PR trigger, we get:
image

But when running with the GitHub Action trigger, we get:
image
(the build also fails because we're using branchName in a lot of places)

Are we missing something? Should this be passed as a variable when using the GitHub Action trigger?

Thanks!

@Josh-01 Josh-01 added bug Something isn't working enhancement New feature or request P1 Some scenario broken but workaround exists question Further information is requested idle Inactive for 14 days and removed question Further information is requested enhancement New feature or request P1 Some scenario broken but workaround exists labels Jan 21, 2022
@tjcorr
Copy link
Contributor

tjcorr commented Aug 23, 2023

I would recommend using the Azure Pipeline App in the GitHub marketplace: https://github.com/marketplace/azure-pipelines. Using this app will allow you to directly trigger a Azure Pipeline without the need for GitHub Actions at all. I believe this will also make all the ADO build variables function as expected.

@vwnj84
Copy link

vwnj84 commented Jul 2, 2024

@tjcorr Who actually supports the app? We've had all kinds of trouble with that integration and Microsoft support treats it as if they've never heard of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working idle Inactive for 14 days P1 Some scenario broken but workaround exists
Projects
None yet
Development

No branches or pull requests

4 participants