Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

基于Coding使用CloudBase Framework的技巧:上传官方镜像到制品库以提高构建效率 #211

Open
Guo-Zhang opened this issue May 15, 2021 · 1 comment

Comments

@Guo-Zhang
Copy link

Guo-Zhang commented May 15, 2021

官方对于CI流程的说明文档:https://docs.cloudbase.net/framework/ci.html。

个别时候可能会因为Docker Hub在大陆节点不稳定而导致构建异常,我这里做了一个CI用来拉取官方镜像到自己的制品库里。Jenkinfile如下:

pipeline {
  agent any
  stages {
    stage('拉取Docker Hub镜像') {
      steps {
        script {
          docker.image("$DOCKER_REGISTRY_NAME/$DOCKER_IMAGE_NAME:$DOCKER_TAG_NAME").pull()
        }

      }
    }
    stage('推送到制品库') {
      steps {
        script {
          sh "docker tag $DOCKER_REGISTRY_NAME/$DOCKER_IMAGE_NAME:$DOCKER_TAG_NAME quanttide-docker.pkg.coding.net/$PROJECT_NAME/$DOCKER_REGISTRY_NAME/$DOCKER_IMAGE_NAME"
          docker.withRegistry("https://$CCI_CURRENT_TEAM-docker.pkg.coding.net/$PROJECT_NAME/$DOCKER_REGISTRY_NAME", "$CODING_ARTIFACTS_CREDENTIALS_ID") {
            sh "docker push $CCI_CURRENT_TEAM-docker.pkg.coding.net/$PROJECT_NAME/$DOCKER_REGISTRY_NAME/$DOCKER_IMAGE_NAME"
          }
        }

      }
    }
  }
}

需要用户填写三/四个环境变量:

  • DOCKER_REGISTRY_NAME: tencentcloudbase,镜像仓库名称,需要在构建计划同项目下创建一个和Docker Hub镜像仓库同名的Docker制品库。
  • DOCKER_IMAGE_NAME: cloudbase-framework-runner,镜像名称。
  • DOCKER_TAG_NAME: latest,镜像版本名称。
  • CCI_CURRENT_TEAM: <your-company-name-for-coding>, Coding企业名称,这个环境变量目前是即将上线状态,请开发者在没上线之前自行填写,详见:https://help.coding.net/docs/ci/env.html。

如果开发者想根据自己需求定制,可以对模板进行修改,再次不再赘述。

推荐开发者调试通过以后保存成团队构建计划以方便复用。

@Guo-Zhang Guo-Zhang changed the title Coding使用技巧:上传官方镜像到制品库以提高构建效率 基于Coding使用CloudBase Framework的技巧:上传官方镜像到制品库以提高构建效率 May 15, 2021
@binggg
Copy link
Collaborator

binggg commented May 17, 2021

👍,感谢建议

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants