代码拉取完成,页面将自动刷新
pipeline {
agent {
node {
label 'gradle'
}
}
stages {
stage('拉取代码') {
agent none
steps {
container('gradle') {
git(url: 'https://gitee.com/gt454612555/sell-user.git', credentialsId: 'git-ee', branch: 'master', changelog: true, poll: false)
sh 'ls '
}
}
}
stage('项目编译') {
agent none
steps {
container('gradle') {
sh 'gradle --stop'
sh '''if [ $REFRESH = \'true\' ];then
gradle --refresh-dependencies clean bootJar
else
gradle clean bootJar
fi'''
sh 'ls -la'
}
}
}
stage('构建镜像') {
agent none
steps {
container('gradle') {
sh 'docker build -t $APP_NAME:latest . '
}
}
}
stage('推送镜像') {
agent none
steps {
container('gradle') {
withCredentials([usernamePassword(credentialsId : 'docker-guotuo' ,passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker tag $APP_NAME:latest $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('deploy to test') {
steps {
container('gradle') {
withCredentials([kubeconfigFile(credentialsId : env.KUBECONFIG_CREDENTIAL_ID ,variable : 'KUBECONFIG' )]) {
sh 'envsubst < deploy/deploy.yml | kubectl apply -f -'
}
}
}
}
}
environment {
DOCKER_CREDENTIAL_ID = 'dockerhub-id'
GITHUB_CREDENTIAL_ID = 'github-id'
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
REGISTRY = 'registry.cn-hangzhou.aliyuncs.com'
DOCKERHUB_NAMESPACE = 'gt_sell'
GITHUB_ACCOUNT = 'kubesphere'
APP_NAME = 'sell-user'
}
parameters {
choice choices: ['true', 'false'], description: '是否强制刷新jar包依赖', name: 'REFRESH'
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。