因为公司前端项目使用pnpm,使用devops部署前端项目时要用到pnpm,废话不多说,直接上代码,node版本16.10 pnpm版本7.14.1
pipeline {
agent {
kubernetes {
inheritFrom 'nodejs base'
containerTemplate {
name 'nodejs'
image 'node:16.10.0'
}
}
}
stages {
stage('clone code') {
agent none
steps {
container('maven') {
git(url: 'xxx', credentialsId: 'xxxx', branch: 'master', changelog: true, poll: false)
}
}
}
stage('unit test') {
agent none
steps {
container('nodejs') {
sh 'npm install -g pnpm@7.14.1 --registry=https://registry.npmmirror.com'
sh '''pnpm config set registry https://registry.npmmirror.com
'''
sh 'pnpm i'
}
}
}
stage('stage-6ptvr') {
agent none
steps {
sh 'ls -al'
sh 'ls ./dist'
}
}
}
environment {
DOCKER_CREDENTIAL_ID = 'dockerhub-id'
GITHUB_CREDENTIAL_ID = 'github-id'
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
REGISTRY = 'docker.io'
DOCKERHUB_NAMESPACE = 'docker_username'
GITHUB_ACCOUNT = 'kubesphere'
APP_NAME = 'devops-java-sample'
}
parameters {
string(name: 'TAG_NAME', defaultValue: '', description: '')
}
}