Brc's blog
首页
前端
后端
运维
  • 工作笔记
  • 分类
  • 标签
  • 归档
关于

Brc

努力中
首页
前端
后端
运维
  • 工作笔记
  • 分类
  • 标签
  • 归档
关于
  • 工具安装

  • AWS

  • EKS

    • 扩缩容

    • 存储

    • devops

    • test

    • CICD

      • 凭证
      • 配置字典
      • 存储卷
      • java
      • crm
      • front
      • upload-to-gcs
        • Jenkinsfile
    • 问题
  • 其他

  • AWS创建EKS集群
  • 谷歌云创建GKE集群
  • 工作笔记
  • EKS
  • CICD
Brc
2023-06-29
目录

upload-to-gcs

  1. 配置一个服务账号,配置操作Cloud Storage的权限,创建密钥并保存命名空间kubesphere-devops-worker中的配置字典dokimet-gcloud-config里面;
  2. 下载google-cloud-cli-436.0.0-linux-x86_64.tar.gz并保存在命名空间kubesphere-devops-worker中的pvcdokimet-google-data-pvc里面;
  3. 创建存储桶game.birenchong.cn,在权限中给allUsers分配Storage Object Viewer角色;

# Jenkinsfile

pipeline {
  agent {
    kubernetes {
      label 'cocos'
      yaml '''apiVersion: v1
kind: Pod
spec:
  containers:
  - name: "base"
    image: "kubesphere/builder-python:v3.2.0"
    command: [\'cat\']
    tty: true
    volumeMounts:
    - mountPath: "/home/jenkins/google"
      name: "google-data-volume"
      readOnly: false
    - mountPath: "/home/jenkins/send_dingding.sh"
      name: "dingding-script-volume"
      subPath: "send_dingding.sh"
    - mountPath: "/root/.google/config.json"
      name: "config-volume"
      subPath: "config.json"
    - mountPath: "/var/run/docker.sock"
      name: "volume-0"
      readOnly: false
    - mountPath: "/home/jenkins/agent"
      name: "workspace-volume"
      readOnly: false
  nodeSelector:
    env-devops: 'true'
  volumes:
  - name: "google-data-volume"
    persistentVolumeClaim:
      claimName: "birenchong-google-data-pvc"
  - hostPath:
      path: "/var/run/docker.sock"
    name: "volume-0"
  - emptyDir:
      medium: ""
    name: "workspace-volume"
  - configMap:
      items:
      - key: "charged-atlas-35xxx7-ca2xxxxxxxxx3.json"
        path: "config.json"
      name: "birenchong-gcloud-config"
    name: "config-volume"
  - configMap:
      items:
      - key: "send_dingding.sh"
        path: "send_dingding.sh"
      name: "birenchong-jenkins-dingding-script"
    name: "dingding-script-volume"
'''
    }

  }
  stages {

    stage('配置google凭证') {
      agent none
      steps {
        container('base') {
          sh 'cp /home/jenkins/google/google-cloud-cli-436.0.0-linux-x86_64.tar.gz .'
          sh 'tar -xf google-cloud-cli-436.0.0-linux-x86_64.tar.gz'
          sh './google-cloud-sdk/install.sh -q'
          sh './google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=/root/.google/config.json'
        }

      }
    }

    stage('推送到gs') {
      agent none
      steps {
        container('base') {
          sh 'mv build/web-mobile/index.html build/web-mobile/index-${BUILD_NUMBER}.html'
          sh './google-cloud-sdk/bin/gsutil cp -r build/web-mobile/* gs://game.birenchong.cn/${APP_NAME}/${BRANCH_NAME}/'
        }

      }
    }

  }

  environment {
    APP_NAME = 'birenchong'
  }

  post {
    success {
      container('base') {
        sh 'bash /home/jenkins/send_dingding.sh "构建成功" "https://game.birenchong.cn/${APP_NAME}/${BRANCH_NAME}/index-${BUILD_NUMBER}.html"'
      }
    }

    failure {
      container('base') {
        sh 'bash /home/jenkins/send_dingding.sh "构建失败"'
      }
    }

    aborted {
      container('base') {
        sh 'bash /home/jenkins/send_dingding.sh "取消构建"'
      }
    }
  }

}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#Cloud Storage
Last Updated: 2023/11/08, 14:45:54
front
问题

← front 问题→

最近更新
01
谷歌云创建GKE集群
07-26
02
ElastiCacheForRedis启用密码
07-26
03
yapi
06-11
更多文章>
Theme by Vdoing | Copyright © 2021-2024 Brc | MIT License | 浙ICP备19031881号-4
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式