代码拉取完成,页面将自动刷新
同步操作将从 FenG_Vnc/devops-maven-sample 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
pipeline {
agent {
node {
label 'maven'
}
}
parameters {
string(name:'REGISTRY',defaultValue: 'harbor.internal.virtueit.net',description:'镜像仓库地址')
string(name:'DOCKERHUB_NAMESPACE',defaultValue: 'devops',description:'')
string(name:'APP_NAME',defaultValue: 'devops-sample',description:'')
}
environment {
DOCKER_CREDENTIAL_ID = 'harbor'
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
DOCKERHUB_NAMESPACE = 'devops'
APP_NAME = 'devops-java-sample'
}
stages {
stage('Checkout SCM') {
agent none
steps {
git(url: 'https://gitee.com/smjg_001/devops-maven-sample.git', credentialsId: 'gitlab', changelog: true, poll: false)
}
}
// stage('Unit Test') {
// agent none
// steps {
// container('maven') {
// sh '''mvn clean -gs `pwd`/configuration/settings.xml test
// '''
// }
// }
// }
stage('Build and Push') {
agent none
steps {
container('maven') {
sh '''mvn -Dmaven.test.skip=true clean package
'''
sh '''docker build -f Dockerfile-online -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER .
'''
withCredentials([usernamePassword(credentialsId : 'harbor' ,passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,)]) {
sh '''echo "$DOCKER_PASSWORD" | docker login $REGISTRY -u "$DOCKER_USERNAME" --password-stdin
'''
sh '''docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER
'''
}
}
}
}
stage('Artifacts') {
agent none
steps {
archiveArtifacts 'target/*.jar'
}
}
stage('Deploy to Dev') {
agent none
steps {
// input(message: '@admin ', submitter: 'admin')
container('maven') {
withCredentials([kubeconfigContent(credentialsId : 'kubeconfig' ,variable : 'KUBECONFIG_CONTENT' ,)]) {
sh '''mkdir ~/.kube
echo "$KUBECONFIG_CONTENT" > ~/.kube/config
envsubst < deploy/dev/deployment.yaml | kubectl apply -f -
envsubst < deploy/dev/service.yaml | kubectl apply -f -
'''
}
}
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。