flutterazure-devopsazure-pipelines-build-task

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?


Solution

  • 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: you@vs-ssh.visualstudio.com:v3/you/project/repo_name
    
    

    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