ci: add production tag pipeline
This commit is contained in:
@@ -0,0 +1,97 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
parameters {
|
||||||
|
gitParameter(
|
||||||
|
name: 'RELEASE_TAG',
|
||||||
|
type: 'PT_TAG',
|
||||||
|
tagFilter: 'v*',
|
||||||
|
branchFilter: 'origin/(.*)',
|
||||||
|
sortMode: 'DESCENDING_SMART',
|
||||||
|
selectedValue: 'TOP',
|
||||||
|
useRepository: 'http://127.0.0.1:3001/my-project/access-manage.git',
|
||||||
|
quickFilterEnabled: true,
|
||||||
|
listSize: '10',
|
||||||
|
requiredParameter: true,
|
||||||
|
description: '请选择要部署到生产环境的 Git Tag。列表自动来自当前项目仓库,生产只能从 Tag 发布。'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
CI = 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
options {
|
||||||
|
timestamps()
|
||||||
|
disableConcurrentBuilds()
|
||||||
|
buildDiscarder(logRotator(numToKeepStr: '10'))
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Checkout Tag') {
|
||||||
|
steps {
|
||||||
|
checkout([
|
||||||
|
$class: 'GitSCM',
|
||||||
|
branches: [[name: '*/master']],
|
||||||
|
userRemoteConfigs: [[
|
||||||
|
url: 'http://127.0.0.1:3001/my-project/access-manage.git'
|
||||||
|
]]
|
||||||
|
])
|
||||||
|
sh '''
|
||||||
|
set -eu
|
||||||
|
test -n "$RELEASE_TAG"
|
||||||
|
NORMALIZED_RELEASE_TAG="$(printf '%s' "$RELEASE_TAG" | sed 's/\\^{}$//')"
|
||||||
|
echo "Deploying production tag: $NORMALIZED_RELEASE_TAG"
|
||||||
|
git fetch --tags --force
|
||||||
|
git checkout -f "refs/tags/$NORMALIZED_RELEASE_TAG"
|
||||||
|
git describe --tags --exact-match HEAD
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Env') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
git --version
|
||||||
|
node -v
|
||||||
|
corepack --version
|
||||||
|
corepack enable
|
||||||
|
corepack prepare pnpm@11.5.0 --activate
|
||||||
|
pnpm -v
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Install') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
pnpm install --frozen-lockfile
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Check') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
pnpm typecheck
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
pnpm build:pro
|
||||||
|
test -f dist/server.js
|
||||||
|
test -f dist/db/migrate.js
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Deploy Production') {
|
||||||
|
steps {
|
||||||
|
sh 'sudo /usr/local/bin/deploy-access-manage-from-jenkins "$WORKSPACE"'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user