Jenkinsfile 1.7 KB

123456789101112131415161718192021222324252627282930313233
  1. def SVC = [prodDir: 'store-platform', deployName: 'store-platform']
  2. def sparseCheckoutProduShared() {
  3. checkout scm: [$class: 'GitSCM', branches: scm.branches,
  4. extensions: [[$class: 'CloneOption', depth: 1, shallow: true, noTags: true],
  5. [$class: 'SparseCheckoutPaths', sparseCheckoutPaths: [[path: 'docs/jenkins/produ/_shared/']]]],
  6. userRemoteConfigs: scm.userRemoteConfigs]
  7. }
  8. pipeline {
  9. agent any
  10. options { buildDiscarder(logRotator(numToKeepStr: '15')); timestamps(); timeout(time: 45, unit: 'MINUTES') }
  11. parameters {
  12. string(name: 'SOURCE_TAG', defaultValue: 'uat-latest', trim: true,
  13. description: 'Harbor UAT tag,默认 uat-latest;回滚填 uat-build-<N>')
  14. string(name: 'TARGET_TAG', defaultValue: '', trim: true)
  15. string(name: 'HARBOR_REGISTRY', defaultValue: '39.105.153.68', trim: true)
  16. string(name: 'HARBOR_PROJECT', defaultValue: 'alien_cloud', trim: true)
  17. choice(name: 'DEPLOY_STRATEGY', choices: ['rolling', 'canary', 'skip'])
  18. string(name: 'CANARY_WEIGHT', defaultValue: '10', trim: true)
  19. string(name: 'K8S_NAMESPACE', defaultValue: 'alien-produ', trim: true)
  20. booleanParam(name: 'DRY_RUN', defaultValue: false)
  21. }
  22. environment { HARBOR_CREDENTIALS = 'harbor-robot-alien'; KUBECONFIG_CREDENTIALS = 'ack-kubeconfig-alien' }
  23. stages {
  24. stage('Promote image & Deploy ACK') {
  25. steps { script {
  26. sparseCheckoutProduShared()
  27. def k8s = load 'docs/jenkins/produ/_shared/k8s-produ-lib.groovy'
  28. k8s.promoteOneServiceToAck(this, SVC)
  29. echo ">>> store-platform: ${env.IMAGE_REF}"
  30. } }
  31. }
  32. }
  33. }