持续集成
pnpm 可以很容易地用于各种持续集成系统。
🌐 pnpm can easily be used in various continuous integration systems.
在所有提供的配置文件中,存储都是缓存的。然而,这并不是必须的,而且不能保证缓存存储会加快安装速度。因此,在你的任务中可以自由选择不缓存 pnpm 存储。
🌐 In all the provided configuration files the store is cached. However, this is not required, and it is not guaranteed that caching the store will make installation faster. So feel free to not cache the pnpm store in your job.
AppVeyor
在 AppVeyor 上,你可以通过将其添加到你的 appveyor.yml 来使用 pnpm 安装依赖:
🌐 On AppVeyor, you can use pnpm for installing your dependencies by adding this
to your appveyor.yml:
install:
- ps: Install-Product node $env:nodejs_version
- npm install --global corepack@latest
- corepack enable
- corepack prepare pnpm@next-11 --activate
- pnpm install
Azure 管道
🌐 Azure Pipelines
在 Azure Pipelines 中,你可以通过将此添加到你的 azure-pipelines.yml 来使用 pnpm 安装和缓存依赖:
🌐 On Azure Pipelines, you can use pnpm for installing and caching your dependencies by adding this to your azure-pipelines.yml:
variables:
pnpm_config_cache: $(Pipeline.Workspace)/.pnpm-store
steps:
- task: Cache@2
inputs:
key: 'pnpm | "$(Agent.OS)" | pnpm-lock.yaml'
path: $(pnpm_config_cache)
displayName: Cache pnpm
- script: |
npm install --global corepack@latest
corepack enable
corepack prepare pnpm@next-11 --activate
pnpm config set store-dir $(pnpm_config_cache)
displayName: "Setup pnpm"
- script: |
pnpm install
pnpm run build
displayName: "pnpm install and build"
Bitbucket 管道
🌐 Bitbucket Pipelines
你可以使用 pnpm 来安装和缓存依赖:
🌐 You can use pnpm for installing and caching your dependencies:
definitions:
caches:
pnpm: $BITBUCKET_CLONE_DIR/.pnpm-store
pipelines:
pull-requests:
"**":
- step:
name: Build and test
image: node:18.17.1
script:
- npm install --global corepack@latest
- corepack enable
- corepack prepare pnpm@next-11 --activate
- pnpm install
- pnpm run build # Replace with your build/test…etc. commands
caches:
- pnpm
CircleCI
在 CircleCI 上,你可以通过将此添加到你的 .circleci/config.yml 来使用 pnpm 安装和缓存依赖:
🌐 On CircleCI, you can use pnpm for installing and caching your dependencies by adding this to your .circleci/config.yml:
version: 2.1
jobs:
build: # this can be any name you choose
docker:
- image: node:18
resource_class: large
parallelism: 10
steps:
- checkout
- restore_cache:
name: Restore pnpm Package Cache
keys:
- pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
- run:
name: Install pnpm package manager
command: |
npm install --global corepack@latest
corepack enable
corepack prepare pnpm@next-11 --activate
pnpm config set store-dir .pnpm-store
- run:
name: Install Dependencies
command: |
pnpm install
- save_cache:
name: Save pnpm Package Cache
key: pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
paths:
- .pnpm-store
GitHub 操作
🌐 GitHub Actions
在 GitHub Actions 上,你可以使用 pnpm 来安装和缓存依赖,方法如下(放在 .github/workflows/NAME.yml 中):
🌐 On GitHub Actions, you can use pnpm for installing and caching your dependencies
like so (belongs in .github/workflows/NAME.yml):
name: pnpm Example Workflow
on:
push:
jobs:
build:
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 11
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install
GitLab CI
在 GitLab 上,你可以使用 pnpm 来安装和缓存你的依赖,方法如下(放在 .gitlab-ci.yml 中):
🌐 On GitLab, you can use pnpm for installing and caching your dependencies
like so (belongs in .gitlab-ci.yml):
stages:
- build
build:
stage: build
image: node:18.17.1
before_script:
- npm install --global corepack@latest
- corepack enable
- corepack prepare pnpm@next-11 --activate
- pnpm config set store-dir .pnpm-store
script:
- pnpm install # install dependencies
cache:
key:
files:
- pnpm-lock.yaml
paths:
- .pnpm-store
Jenkins
你可以使用 pnpm 来安装和缓存依赖:
🌐 You can use pnpm for installing and caching your dependencies:
pipeline {
agent {
docker {
image 'node:lts-bullseye-slim'
args '-p 3000:3000'
}
}
stages {
stage('Build') {
steps {
sh 'npm install --global corepack@latest'
sh 'corepack enable'
sh 'corepack prepare pnpm@next-11 --activate'
sh 'pnpm install'
}
}
}
}
信号
🌐 Semaphore
在 Semaphore 上,你可以通过在你的 .semaphore/semaphore.yml 文件中添加以下内容来使用 pnpm 安装和缓存依赖:
🌐 On Semaphore, you can use pnpm for installing and caching your dependencies by
adding this to your .semaphore/semaphore.yml file:
version: v1.0
name: Semaphore CI pnpm example
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
blocks:
- name: Install dependencies
task:
jobs:
- name: pnpm install
commands:
- npm install --global corepack@latest
- corepack enable
- corepack prepare pnpm@next-11 --activate
- checkout
- cache restore node-$(checksum pnpm-lock.yaml)
- pnpm install
- cache store node-$(checksum pnpm-lock.yaml) $(pnpm store path)
Travis
在 Travis CI 上,你可以通过在你的 .travis.yml 文件中添加以下内容来使用 pnpm 安装依赖:
🌐 On Travis CI, you can use pnpm for installing your dependencies by adding this
to your .travis.yml file:
cache:
npm: false
directories:
- "~/.pnpm-store"
before_install:
- npm install --global corepack@latest
- corepack enable
- corepack prepare pnpm@next-11 --activate
- pnpm config set store-dir ~/.pnpm-store
install:
- pnpm install