gpt4 book ai didi

azure - 如何在 Azure Pipelines 上使用 pnpm?

转载 作者:行者123 更新时间:2023-12-02 06:02:06 32 4
gpt4 key购买 nike

在我的 Nextjs 项目中,我想使用 Azure Pipelines 创建管道。但我的项目使用 pnpm 包管理器。我读过 pnpm 文档,只知道 Travis、Semaphore、AppVeyor、GitHub Actions、Gitlab CI 和 Bitbucket Pipelines。没有 Azure Pipelines 文档。

有人知道如何实现吗?

最佳答案

我为 Azure 管道中的管道创建了自己的配方。

任何反馈都会有用

对于 Nextjs

azure-pipelines.yml

variables:
pnpm_config_cache: $(Pipeline.Workspace)/.pnpm-store

trigger:
- main

pool:
vmImage: ubuntu-latest

steps:
- task: Cache@2
inputs:
key: 'pnpm | "$(Agent.OS)" | pnpm-lock.yaml'
path: $(pnpm_config_cache)
displayName: Cache pnpm

- task: Cache@2
inputs:
key: next | $(Agent.OS) | pnpm-lock.yaml
path: "$(System.DefaultWorkingDirectory)/.next/cache"
displayName: "Cache .next/cache"

- script: |
curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@7
pnpm config set store-dir $(pnpm_config_cache)
displayName: "Setup pnpm"

- script: |
pnpm install
pnpm run build
displayName: "pnpm install and build"

- task: ArchiveFiles@2
inputs:
rootFolderOrFile: "."
includeRootFolder: false
archiveType: "zip"
archiveFile: "$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip"
replaceExistingArchive: true

- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: "$(Build.ArtifactStagingDirectory)"
ArtifactName: "drop"
publishLocation: "Container"

对于其他构建(删除了 Nextjs 部分的版本)

azure-pipelines.yml

variables:
pnpm_config_cache: $(Pipeline.Workspace)/.pnpm-store

trigger:
- main

pool:
vmImage: ubuntu-latest

steps:
- task: Cache@2
inputs:
key: 'pnpm | "$(Agent.OS)" | pnpm-lock.yaml'
path: $(pnpm_config_cache)
displayName: Cache pnpm

- script: |
curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@7
pnpm config set store-dir $(pnpm_config_cache)
displayName: "Setup pnpm"

- script: |
pnpm install
pnpm run build
displayName: "pnpm install and build"

- task: ArchiveFiles@2
inputs:
rootFolderOrFile: "."
includeRootFolder: false
archiveType: "zip"
archiveFile: "$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip"
replaceExistingArchive: true

- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: "$(Build.ArtifactStagingDirectory)"
ArtifactName: "drop"
publishLocation: "Container"

关于azure - 如何在 Azure Pipelines 上使用 pnpm?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73117288/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com