Checkout specific ref in Azure Pipeline from private GitHub



  • I'm facing a problem when trying to use a parameter in my resources.

    parameters:
    - name: MyVersion
      default: "0.0.0"
    

    resources:
    repositories:

    • repository: other
      type: github
      name: mycompany/project
      #Ref with parameter is not allowed
      ref: refs/tags/tag_${{parameters.MyVersion}}
      endpoint: mygithub

    While https://stackoverflow.com/questions/72400534/checkout-different-repository-as-per-input-in-azure-pipeline could potentially help, it doesn't work for me because I'm using GitHub. How do I do the same thing with GitHub?

    I tried

    - checkout: git://mycompany/project@refs/tags/tag_${{parameters.MyVersion}}
    

    But it tells me "mycompany" doesn't exist. Which makes sense because mycompany is on GitHub and not in Azure DevOps. How do I help Azure DevOps find it? Also, this is a private project that requires authentication for checkout.



  • Thanks to @M Karimi's suggestion in comments I ended up doing a manual checkout from github with PAT

      - checkout: none
      - script: |
        git clone https://$(GITHUBPAT)@github.com/mycompany/project.git
        git checkout refs/tags/tag_${{parameters.MyVersion}}
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2