78 lines
2.2 KiB
Plaintext
78 lines
2.2 KiB
Plaintext
pipeline {
|
|
agent {
|
|
node {
|
|
label 'maven'
|
|
}
|
|
|
|
}
|
|
stages {
|
|
stage('拉取代码') {
|
|
agent none
|
|
steps {
|
|
container('maven') {
|
|
git(url: 'https://gitee.com/hongtaohu/RuoYi-Cloud.git', credentialsId: 'gitee-id', branch: 'master', changelog: true, poll: false)
|
|
sh 'ls -al'
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
stage('项目编译') {
|
|
agent none
|
|
steps {
|
|
container('maven') {
|
|
sh 'ls -al'
|
|
sh 'mvn clean package -Dmaven.test.skip=true'
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
stage('构建ruoyi-monitor镜像') {
|
|
agent none
|
|
steps {
|
|
container('maven') {
|
|
sh 'ls ruoyi-visual/ruoyi-monitor/target'
|
|
sh 'docker build -t ruoyi-monitor:latest -f ruoyi-visual/ruoyi-monitor/Dockerfile ./ruoyi-visual/ruoyi-monitor/'
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
stage('推送ruoyi-monitor镜像') {
|
|
agent none
|
|
steps {
|
|
container('maven') {
|
|
withCredentials([usernamePassword(credentialsId : 'harbor-registry' ,passwordVariable : 'HARBOR_PWD_TEXT' ,usernameVariable : 'HARBOR_USER_TEXT' ,)]) {
|
|
sh 'echo "$HARBOR_PWD_TEXT" | docker login $REGISTRY -u "$HARBOR_USER_TEXT" --password-stdin'
|
|
sh 'docker tag ruoyi-monitor:latest $REGISTRY/$HARBOR_NAMESPACE/ruoyi-monitor:SNAPSHOT-$BUILD_NUMBER'
|
|
sh 'docker push $REGISTRY/$HARBOR_NAMESPACE/ruoyi-monitor:SNAPSHOT-$BUILD_NUMBER'
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
stage('部署ruoyi-monitor到dev环境') {
|
|
agent none
|
|
steps {
|
|
kubernetesDeploy(configs: 'ruoyi-visual/ruoyi-monitor/deploy/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
|
|
}
|
|
}
|
|
|
|
}
|
|
environment {
|
|
DOCKER_CREDENTIAL_ID = 'dockerhub-id'
|
|
GITHUB_CREDENTIAL_ID = 'github-id'
|
|
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
|
|
REGISTRY = '192.168.2.147:30002'
|
|
DOCKERHUB_NAMESPACE = 'docker_username'
|
|
GITHUB_ACCOUNT = 'kubesphere'
|
|
APP_NAME = 'devops-java-sample'
|
|
HARBOR_NAMESPACE = 'ruoyi'
|
|
}
|
|
parameters {
|
|
string(name: 'TAG_NAME', defaultValue: '', description: '')
|
|
}
|
|
} |