Salesforce通用框架通过devops解决依赖关系

问题描述 投票:0回答:1

作为 Azure DevOps 工程师,我们使用 Salesforce CLI 将 CI/CD 自动化到 Salesforce org。我们有多个项目(每个都有一个存储库),它们具有不同 Salesforce 项目的代码库。

来自不同分支的代码库按照分支策略部署到 Salesforce 组织。

示例:

  • 项目名称:myProject
  • 存储库:myProjectRepository
  • 分支:功能、开发、发布和主要
  • Salesforce 组织:DEV、SIT、UAT、PROD

计划创建通用框架(触发器、记录器、错误处理等)并将它们推送到新的通用存储库并维护版本控制。然后,Salesforce 项目可以使用任何版本的通用框架作为依赖项。

示例:

  • 项目名称:myCommonFramework
  • 存储库:myCommonFrameworkRepository
  • 分支:功能、开发和发布

我检查了 sfdx-project.json 中的“packageDirectories”,要求该文件夹位于 --source-dir 中。我没有找到将所需版本链接为 package.json 中的“devDependency”或/和“dependencies”的方法。

请问您对此解决方案有什么想法吗?

azure-devops salesforce salesforce-sfdx
1个回答
0
投票

在 Azure DevOps 中,如果要将代码文件从

myCommonFrameworkRepository
下载到
myProjectRepository
,可以将
myCommonFrameworkRepository
定义为
myProjectRepository
管道中的存储库资源。

  1. 如果两个存储库位于同一 Azure DevOps 组织内的同一项目中。在

    myProjectRepository
    的YAML管道中,您可以像下面这样进行配置。

    # azure-pipelines.yml
    
    # Set 'myCommonFrameworkRepository' as a repository resource in this pipeline.
    resources:
      repositories:
      - repository: commonFrameworkRepo  # A customized alias for the repository resource.
        type: git  # Azure Git Repos.
        name: myCommonFrameworkRepository  # The actual name of 'myCommonFrameworkRepository'. 
        ref: main  # The branch checked out by default from 'myCommonFrameworkRepository'.
    
    stages:
    - stage: A
      jobs:
      - job: A1
        steps:
        # Check out files from 'myProjectRepository'.
        - checkout: self
        # Check out files from 'myCommonFrameworkRepository'.
        - checkout: commonFrameworkRepo
    
  2. 如果

    myCommonFrameworkRepository
    位于同一 Azure DevOps 组织内的不同项目(例如,
    myCommonFramework
    )。在
    myProjectRepository
    的YAML管道中,您可以像下面这样进行配置。

    # azure-pipelines.yml
    
    resources:
      repositories:
      - repository: commonFrameworkRepo
        type: git
        name: myCommonFramework/myCommonFrameworkRepository  # projectName/repoName
        ref: main
    
    stages:
    - stage: A
      jobs:
      - job: A1
        steps:
        - checkout: self
        - checkout: commonFrameworkRepo
    
  3. 如果

    myCommonFrameworkRepository
    位于不同的 Azure DevOps 组织中。您需要在 myProjectRepository 的项目中创建
    Azure Repos 服务连接
    ,以连接到
    myCommonFrameworkRepository

    然后在

    myProjectRepository
    的YAML管道中,可以像下面这样进行配置。

    # azure-pipelines.yml
    
    resources:
      repositories:
      - repository: commonFrameworkRepo
        endpoint: myAzGitReposConnection  # Use the Azure Repos service connection.
        type: git
        name: myCommonFramework/myCommonFrameworkRepository  # projectName/repoName
        ref: main
    
    stages:
    - stage: A
      jobs:
      - job: A1
        steps:
        - checkout: self
        - checkout: commonFrameworkRepo
    

更多详情,您可以参考以下文档:


© www.soinside.com 2019 - 2024. All rights reserved.