1 Star 2 Fork 0

万家生佛/gulibase

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Jenkinsfile 2.38 KB
一键复制 编辑 原始数据 按行查看 历史
pipeline {
agent {
node {
label 'maven'
}
}
environment {
DOCKER_CREDENTIAL_ID = 'aliyun-hub-id'
GITHUB_CREDENTIAL_ID = 'github-id'
GITEE_CREDENTIAL_ID = 'gitee-id'
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
REGISTRY = 'registry.cn-hangzhou.aliyuncs.com'
DOCKERHUB_NAMESPACE = 'atguigu_chenxi'
GITHUB_ACCOUNT = 'wanjiashengfo'
APP_NAME = 'devops-java-sample'
SONAR_CREDENTIAL_ID = 'sonar-qube'
BRANCH_NAME = 'master'
}
stages {
stage('拉取代码') {
steps {
git(credentialsId: 'gitee-id', url: 'https://gitee.com/L2018chenxi/gulibase.git', branch: 'master', changelog: true, poll: false)
sh 'echo 正在构建 $PROJECT_NAME 版本号: $PROJECT_VERSION 将会提交给$REGISTRY 镜像仓库'
sh "echo 正在完整编译项目"
container ('maven') {
sh "mvn clean install -Dmaven.test.skip=true -gs `pwd`/mvn-settings.xml"
}
}
}
stage ('构建镜像 推送最新镜像') {
steps {
container ('maven') {
sh 'mvn -Dmaven.test.skip=true -gs `pwd`/mvn-settings.xml clean package'
sh 'cd $PROJECT_NAME && docker build -f Dockerfile -t $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER .'
withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : "$DOCKER_CREDENTIAL_ID" ,)]) {
sh 'echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin'
sh 'docker tag $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest '
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest '
}
}
}
}
stage('部署到k8s') {
steps {
input(id: "deploy-to-dev-$PROJECT_NAME", message: "是否部署到集群中?")
kubernetesDeploy(configs: "$PROJECT_NAME/deploy/**", enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
}
parameters {
string(name: 'PROJECT_VERSION', defaultValue: 'v0.0Beta', description: '项目版本')
string(name: 'PROJECT_NAME', defaultValue: 'gulimall-gateway', description: '构建模块')
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/L2018chenxi/gulibase.git
git@gitee.com:L2018chenxi/gulibase.git
L2018chenxi
gulibase
gulibase
master

搜索帮助