Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use private packages in Azure Pipelines During CI/CD builds

I am using Azure CI/CD pipelines for Flutter build. In my Pubspec yaml file, I have dependencies that are private to my project and the code is hosted in same azure devops project but in different repository. During Build (i.e. Flutter Packages get) it gives me error saying Authentication failed?. I tried with PAT token where in prior to flutter build task i used git command to set that token, but it didn't solve the issue. Can anyone help me out?

like image 226
Gss Aditya Avatar asked Dec 05 '25 20:12

Gss Aditya


1 Answers

I am open to being shown a better way but these are the steps I took to solve this issue a little while ago.

Assuming you are referencing the package in your pubspec.yaml using git over ssh on azure devops like:

  repo_name:
    git:
      ref: 'tag or other identifier'
      url: [email protected]:v3/you/project/repo_name

  • Generate a new ssh key pair on your machine.
  • Upload the private key to the library secure files section on azure devops.
  • Add the install ssh key task to your azure pipelines build, using the key pair generated in the previous steps and referencing the private key uploaded to the secure files library. link
  • Upload the public key to your list of public keys. (This step I'm not 100% sure is necessary but I did it initially and things have worked so I haven't changed removed it)

So in my azure-pipelines.yaml the install ssh key step looks kinda like this where id_rsa is the name of the private key in my secure files.

          - task: InstallSSHKey@0
            inputs:
              knownHostsEntry: 'vs-ssh.visualstudio.com, ...etc'
              sshPublicKey: 'ssh-rsa ...etc'
              sshKeySecureFile: id_rsa

like image 55
Chad Lamb Avatar answered Dec 08 '25 11:12

Chad Lamb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!