58 lines
2.3 KiB
Plaintext
58 lines
2.3 KiB
Plaintext
pipeline {
|
||
agent any
|
||
|
||
environment {
|
||
// git账号,不用改
|
||
GIT_CREDENTIAL_ID = '175776d4-6bbc-4da1-ace2-f2a89453fba4'
|
||
// git地址
|
||
GIT_ADDRESS = 'https://git.mall4j.com/tmerclub/tmerclub-multishop'
|
||
// git分支
|
||
GIT_BRANCH = 'master'
|
||
|
||
// harbor账号,不用改
|
||
HARBOR_CREDENTIAL_ID = 'edd44d2d-f182-40ab-8e72-b4fcae6f793f'
|
||
// harbor地址
|
||
HARBOR_ADDR = '192.168.1.11:80'
|
||
// 名命空间
|
||
NAMESPACE = 'tmerclub-release'
|
||
}
|
||
stages {
|
||
stage ('拉取git仓库代码') {
|
||
steps {
|
||
checkout([$class: 'GitSCM', branches: [[name: '*/' + "$GIT_BRANCH"]], extensions: [], userRemoteConfigs: [[credentialsId: "$GIT_CREDENTIAL_ID", url: "$GIT_ADDRESS"]]])
|
||
}
|
||
}
|
||
stage ('通过npm构建项目') {
|
||
steps {
|
||
sh '''export PATH=/var/jenkins_home/nodejs/bin:$PATH
|
||
rm -f .env.production
|
||
tee ./.env.production <<-'EOF'
|
||
|
||
// api接口请求地址
|
||
VITE_APP_BASE_API = 'https://cloud-api.mall4j.com'
|
||
// 客服webstock接口请求地址 如果是ip的话用 ws,wss对应的是https
|
||
VITE_APP_WEBSOCKET_URL = 'wss://cloud-api.mall4j.com'
|
||
VITE_APP_RESOURCES_URL = 'https://mall4j-minio.mall4j.com/tmerclub'
|
||
EOF
|
||
|
||
sed -i "s#cloud-multishop.mall4j.com#cloud-multishop.mall4j.com#g" nginx.conf
|
||
npm config set registry https://registry.npmmirror.com
|
||
pnpm install --no-frozen-lockfile
|
||
pnpm run build'''
|
||
}
|
||
}
|
||
stage('构建tmerclub-multishop-vue镜像') {
|
||
steps {
|
||
withEnv(["PROJECT_NAME=tmerclub-multishop-vue"]) {
|
||
sh 'docker build -t $HARBOR_ADDR/$NAMESPACE/$PROJECT_NAME:$BUILD_NUMBER .'
|
||
withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : "$HARBOR_CREDENTIAL_ID" ,)]) {
|
||
sh 'echo "$DOCKER_PASSWORD" | docker login $HARBOR_ADDR -u "$DOCKER_USERNAME" --password-stdin'
|
||
sh 'docker push $HARBOR_ADDR/$NAMESPACE/$PROJECT_NAME:$BUILD_NUMBER'
|
||
sh 'ssh root@192.168.1.5 kubectl set image deploy/$PROJECT_NAME $PROJECT_NAME=$HARBOR_ADDR/$NAMESPACE/$PROJECT_NAME:$BUILD_NUMBER -n $NAMESPACE'
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|