Commit a7f89b4d authored by 卢浩元's avatar 卢浩元

Update Jenkinsfile

parent 270c78d9
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
def projectProperties = [ def projectProperties = [
[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '5']], [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '5']],
parameters([ parameters([
string(name: 'DOCKER_USER', defaultValue: '', description: 'docker用户名'), string(name: 'DOCKER_USER', defaultValue: 'admin', description: 'docker用户名'),
string(name: 'DOCKER_PASSWORD', defaultValue: '', description: 'docker用户密码'), string(name: 'DOCKER_PASSWORD', defaultValue: 'K2pass!!', description: 'docker用户密码'),
string(name: 'REGISTRY_URL', defaultValue: 'docker.io', description: 'docker仓库地址') string(name: 'REGISTRY_URL', defaultValue: 'harbor.dev.k2paas.com', description: 'docker仓库地址')
]) ])
] ]
...@@ -14,9 +14,9 @@ properties(projectProperties) ...@@ -14,9 +14,9 @@ properties(projectProperties)
def label = "mypod-${UUID.randomUUID().toString()}" def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label, cloud: 'kubernetes', containers: [ podTemplate(label: label, cloud: 'kubernetes', containers: [
containerTemplate(name: 'maven', image: 'maven:3.6.0-jdk-8', command: 'cat', ttyEnabled: true), containerTemplate(name: 'maven', image: 'harbor.dev.k2paas.com/build/maven:3-jdk-8-alpine', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'docker', image: 'docker', command: 'cat', ttyEnabled: true), containerTemplate(name: 'docker', image: 'harbor.dev.k2paas.com/build/docker:latest', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.10.2', command: 'cat', ttyEnabled: true) containerTemplate(name: 'kubectl', image: 'harbor.dev.k2paas.com/build/k8s-kubectl:v1.14.0', command: 'cat', ttyEnabled: true)
], ],
volumes: [ volumes: [
hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock'), hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock'),
...@@ -65,15 +65,15 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [ ...@@ -65,15 +65,15 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [
} }
stage('docker-build') { stage('docker-build') {
sh "docker build . -t ${params.REGISTRY_URL}/lusyoe/k8s-example:${shortGitCommit}" sh "docker build . -t ${params.REGISTRY_URL}/demo/k8s-example:${shortGitCommit}"
} }
stage('docker-push') { stage('docker-push') {
sh "docker push ${params.REGISTRY_URL}/lusyoe/k8s-example:${shortGitCommit}" sh "docker push ${params.REGISTRY_URL}/demo/k8s-example:${shortGitCommit}"
} }
stage('docker-remove') { stage('docker-remove') {
sh "docker rmi ${params.REGISTRY_URL}/lusyoe/k8s-example:${shortGitCommit}" sh "docker rmi ${params.REGISTRY_URL}/demo/k8s-example:${shortGitCommit}"
} }
} }
...@@ -81,7 +81,7 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [ ...@@ -81,7 +81,7 @@ podTemplate(label: label, cloud: 'kubernetes', containers: [
container('kubectl') { container('kubectl') {
stage('k8s deploy') { stage('k8s deploy') {
sh "sed -i \"s/lusyoe\\/k8s-example/${params.REGISTRY_URL}\\/lusyoe\\/k8s-example:${shortGitCommit}/g\" k8s-example.yaml" sh "sed -i \"s/lusyoe\\/k8s-example/${params.REGISTRY_URL}\\/demo\\/k8s-example:${shortGitCommit}/g\" k8s-example.yaml"
sh "kubectl --kubeconfig=/root/.kube/config apply -f k8s-example.yaml" sh "kubectl --kubeconfig=/root/.kube/config apply -f k8s-example.yaml"
} }
} }
......
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