2 Star 0 Fork 0

郭拓/sell-user

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Jenkinsfile 2.07 KB
一键复制 编辑 原始数据 按行查看 历史
郭拓 提交于 2022-07-22 20:37 . Jenkinsfile的构建参数为选择式
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'
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/gt454612555/sell-user.git
git@gitee.com:gt454612555/sell-user.git
gt454612555
sell-user
sell-user
master

搜索帮助