microsoft / azure-pipelines-agent

Azure Pipelines Agent 🚀
MIT License
1.7k stars 855 forks source link

Fetch Swift Package Dependencies from internal azure repos #4855

Open jinaiyuanbaojie opened 1 week ago

jinaiyuanbaojie commented 1 week ago

Describe your question

Hi team. I am a iOS developer and I am using AzureDevOps in my daily work. I have a iOS repo and it manages its dependencies via Apple official SwiftPackage which I can config the dependency as a git repo. Now I also have some internal dependency libraries on azure repos. And they are referenced by my iOS repo. Then my question is how can I fetch the internal dependencies on our azure pipeline local agent? Are there any solutions or options? TIPS: All of our azure repos can not be public by our policy. And we are enable 2FA(SoftToken PIN) on our azure devops

Versions

Agent version 3.225.3 | MacOS 13.6.6

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Operation system

MacOS Ventura 13.6.6

Version controll system

git

Azure DevOps Server Version (if applicable)

No response

ismayilov-ismayil commented 1 week ago

Hi @jinaiyuanbaojie as I understood you want to retrieve internal ios packages into self-hosted agent, right? if yes, you have several options to do it.

  1. If you dependency is something git repository you can add another checkout steps in the pipeline to pull that package repository into your source folder, then use it.
  2. if it is something in the artifact feed (package repository) then you can create service connection and use it in the pipeline
jinaiyuanbaojie commented 1 week ago

Hi @jinaiyuanbaojie as I understood you want to retrieve internal ios packages into self-hosted agent, right? if yes, you have several options to do it.

  1. If you dependency is something git repository you can add another checkout steps in the pipeline to pull that package repository into your source folder, then use it.
  2. if it is something in the artifact feed (package repository) then you can create service connection and use it in the pipeline

Yeah man. You are right. But the fetching progress is controlled by iOS Swift Package Manage itself. We can only config the git repo address and branch or tag to be referenced in Package.Swift. So I can not use checkout directly

ismayilov-ismayil commented 6 days ago

In this case you can add corresponding permission in the repository branch security section. Then use git reference with $(System.AccessToken) to make it available in your self-hosted agent

jinaiyuanbaojie commented 4 days ago

Hi team, Let us say our team has a repo and it looks like

├── Sources
├── Dummy.xcworkspace
├── README.MD
├── Dependencies
  ├── Package.resolved
  ├── **Package.swift**

And the Package.swift looks like

import PackageDescription

let package = Package(
    name: "MyDependencies",
    platforms: [
        .iOS(.v14),
    ],
    dependencies: [
        **.package(url: "https://azure.internal.com/dummy/thirdparty", from: "1.10.3"),**
    ]
)

We iOS developers config the third-party and internal dependencies into this Package.swift file. For this dummy case, it is https://azure.internal.com/dummy/thirdparty which is our internal azure repo also. The key point is that the progress of git fetch pull or clone is controlled by Apple Official Swift Package it self (swift package resolve). We can not add checkout: xxx at pipeline to address this case.

Is it clear enough for you guys? Any idea?

Thanks in advance. :)

jinaiyuanbaojie commented 4 hours ago

Hi team. Could you give me some suggestion?