1 Star 0 Fork 1

xiaomo/java-devops-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Jenkinsfile 2.47 KB
一键复制 编辑 原始数据 按行查看 历史
xiaomo 提交于 2022-06-09 20:08 . 测试webhook
pipeline {
agent {
node {
label 'maven'
}
}
stages {
stage('拉取代码') {
agent none
steps {
container('maven') {
git(url: 'https://gitee.com/xmlvhy/java-devops-demo.git', credentialsId: 'gitee', branch: 'master', changelog: true, poll: false)
sh 'pwd && ls -alh'
}
}
}
stage('单元测试') {
agent none
steps {
container('maven') {
sh 'mvn clean package -Dmaven.test.skip=true'
sh 'pwd && ls -alh'
}
}
}
stage('镜像构建') {
agent none
steps {
container('maven') {
sh 'ls -alh'
sh '''docker build -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER .
'''
}
}
}
stage('推送镜像') {
agent none
steps {
container('maven') {
withCredentials([usernamePassword(credentialsId: 'aliyun-harbor', passwordVariable: 'DOCKER_PWD_VAR', usernameVariable: 'DOCKER_USER_VAR',)]) {
sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER'
}
}
}
}
stage('部署到dev环境') {
agent none
steps {
container('maven') {
withCredentials([
kubeconfigFile(
credentialsId: env.KUBECONFIG_CREDENTIAL_ID,
variable: 'KUBECONFIG')
]) {
sh 'envsubst < deploy/deploy_codesofun.yaml | 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 = 'codesofun'
GITHUB_ACCOUNT = '1059224309@qq.com'
APP_NAME = 'java-devops-demo'
}
parameters {
string(name: 'TAG_NAME', defaultValue: '', description: '')
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/xmlvhy/java-devops-demo.git
git@gitee.com:xmlvhy/java-devops-demo.git
xmlvhy
java-devops-demo
java-devops-demo
master

搜索帮助