Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f7b529b1bd |
@@ -1,102 +0,0 @@
|
|||||||
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/my-resume.git',
|
|
||||||
quickFilterEnabled: false,
|
|
||||||
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/my-resume.git'
|
|
||||||
]]
|
|
||||||
])
|
|
||||||
sh '''
|
|
||||||
set -eu
|
|
||||||
test -n "$RELEASE_TAG"
|
|
||||||
NORMALIZED_RELEASE_TAG="$(printf '%s' "$RELEASE_TAG" | sed 's/\\^{}$//')"
|
|
||||||
case "$NORMALIZED_RELEASE_TAG" in
|
|
||||||
v[0-9A-Za-z._-]*) ;;
|
|
||||||
*) echo "Invalid release tag: $NORMALIZED_RELEASE_TAG"; exit 2 ;;
|
|
||||||
esac
|
|
||||||
if ! git ls-remote --exit-code --tags origin "refs/tags/$NORMALIZED_RELEASE_TAG" >/dev/null; then
|
|
||||||
echo "Release tag does not exist in repository: $NORMALIZED_RELEASE_TAG"
|
|
||||||
exit 3
|
|
||||||
fi
|
|
||||||
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
|
|
||||||
npm -v
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Install') {
|
|
||||||
steps {
|
|
||||||
sh '''
|
|
||||||
npm ci
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Check') {
|
|
||||||
steps {
|
|
||||||
sh '''
|
|
||||||
node -v
|
|
||||||
npm -v
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Build') {
|
|
||||||
steps {
|
|
||||||
sh '''
|
|
||||||
npm run build:prod
|
|
||||||
test -f dist/index.html
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Deploy Production') {
|
|
||||||
steps {
|
|
||||||
sh 'sudo /usr/local/bin/deploy-my-resume-from-jenkins "$WORKSPACE"'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user