Skip to content

BestBurning/tencentcloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tencentcloud

e.coding.net上用官方提供的demo自动将博客代码推至腾讯COS 不过最后涉及云函数刷新CDN的地方,计费方式过于恐怖,所以用自己的方式去刷新CDN

前置步骤

直到刷新CDN之前与demo保持一致, 之后在coding->项目构建设置中添加一步刷新CDN: cdn

pipeline {
  agent any
  stages {
    stage('检出') {
      steps {
        checkout([
          $class: 'GitSCM',
          branches: [[name: env.GIT_BUILD_REF]],
          userRemoteConfigs: [[url: env.GIT_REPO_URL, credentialsId: env.CREDENTIALS_ID]]
        ])
      }
    }
    stage('部署到腾讯云存储') {
      steps {
        echo '部署中...'
        sh 'coscmd config -a $TENCENT_SECRET_ID -s $TENCENT_SECRET_KEY -b $TENCENT_BUCKET -r $TENCENT_REGION'
        sh 'rm -rf .git'
        sh 'coscmd upload -r ./ /'
        echo '部署完成'
      }
    }
    stage('刷新CDN') {
      steps {
        echo '准备刷新'
        sh 'git clone https://github.com/BestBurning/tencentcloud.git'
        dir(path: './tencentcloud') {
          sh 'mvn clean package '
          sh 'java -jar ./target/tencentcloud-1.0-SNAPSHOT.jar $TENCENT_SECRET_ID $TENCENT_SECRET_KEY $TENCENT_REGION https://di1shuai.com/'
        }
        echo '刷新完毕'
      }
    }
  }
}

参数说明

java -jar ./target/tencentcloud-1.0-SNAPSHOT.jar $TENCENT_SECRET_ID $TENCENT_SECRET_KEY $TENCENT_REGION https://di1shuai.com/
  1. 腾讯云SECRET_ID
  2. 腾讯云SECRET_KEY
  3. 区域
  4. >=4的参数均为要刷新的目录