Commit c263ec99 by Administrator

Update Jenkinsfile

parent 5bb24aa2
pipeline {
agent {label 'jenkins-jnlp'}
triggers {
GenericTrigger(
genericVariables: [
[key: 'ref', value: '$.ref']
],
causeString: 'Triggered on $ref',
token: 'searchhotcrawler123',
printContributedVariables: true,
printPostContent: true,
silentResponse: false,
regexpFilterText: '$ref',
regexpFilterExpression: 'refs/heads/' + BRANCH_NAME
)
}
GenericTrigger(
genericVariables: [
[key: 'ref', value: '$.ref']
],
causeString: 'Triggered on $ref',
token: 'searchhotcrawler123',
printContributedVariables: true,
printPostContent: true,
silentResponse: false,
regexpFilterText: '$ref',
regexpFilterExpression: 'refs/heads/' + BRANCH_NAME
)
}
stages {
stage('Static code inspection') {
steps {
echo "starting codeAnalyze with SonarQube......"
withSonarQubeEnv('sonarqube') {
sh "/apache-maven-3.6.3/bin/mvn clean sonar:sonar"
}
script {
timeout(1) {
waitForQualityGate abortPipeline: true
}
}
}
post {
success {
sh "/usr/local/bin/workwechatctl -p ${env.JOB_NAME} -n 马黎滨 -c 'Code check passed'"
}
failure {
sh "/usr/local/bin/workwechatctl -p ${env.JOB_NAME} -n 马黎滨 -c 'Code check failed, please log in http://sonar.zhiweidata.com to view check information'"
}
}
}
stage('build') {
when { branch 'master' }
steps {
......@@ -32,13 +56,14 @@ pipeline {
}
}
}
stage('build image') {
stage('build image') {
when { branch 'master' }
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub', passwordVariable: 'dockerhubPassword', usernameVariable: 'dockerhubUser')]) {
sh "docker login --username ${dockerhubUser} --password ${dockerhubPassword} harbor.docker.zhiweireach.com"
sh " docker build -t harbor.docker.zhiweireach.com/crawler/searchhot-crawler:${env.BUILD_NUMBER} . "
withCredentials([usernamePassword(credentialsId: 'dockerHub', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) {
sh "docker login -u ${dockerHubUser} -p ${dockerHubPassword} harbor.docker.zhiweireach.com"
sh "docker build -t harbor.docker.zhiweireach.com/daemon/${env.JOB_NAME}:${env.BUILD_NUMBER} . "
}
}
post {
success {
......@@ -49,8 +74,11 @@ stage('build image') {
stage('push image') {
when { branch 'master' }
steps {
sh " docker login --username admin --password JinxiaoZhang...701 harbor.docker.zhiweireach.com"
sh " docker push harbor.docker.zhiweireach.com/crawler/searchhot-crawler:${env.BUILD_NUMBER}"
withCredentials([usernamePassword(credentialsId: 'dockerHub', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) {
sh "docker login -u ${dockerHubUser} -p ${dockerHubPassword} harbor.docker.zhiweireach.com"
sh "docker push harbor.docker.zhiweireach.com/daemon/${env.JOB_NAME}:${env.BUILD_NUMBER}"
}
}
post {
success {
......@@ -61,8 +89,7 @@ stage('build image') {
stage('deploy') {
when { branch 'master' }
steps {
sh "kubectl version"
sh "kubectl -n default set image deployment/searchhot-crawler searchhot-crawler=harbor.docker.zhiweireach.com/crawler/searchhot-crawler:${env.BUILD_NUMBER} --record"
sh "kubectl -n daemon set image deployment/searchhotcrawler searchhotcrawler=harbor.docker.zhiweireach.com/daemon/${env.JOB_NAME}:${env.BUILD_NUMBER} --record"
}
post {
success {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment