Google Cloud Build-无法更新子模块

时间:2019-12-04 16:44:15

标签: google-cloud-build

我将Google Cloud build(GCB)配置为触发我在Github中的一个存储库上的构建。该存储库需要另一个git存储库才能构建。此其他存储库是使用git子模块配置的。

我正在搜索,目前看来GCB不支持子模块。因此,我尝试在GCB下载的源代码上手动运行git submodule update --init,但是上面没有.git目录,并且命令失败。

我在这里想念什么?

我将此问题作为参考:https://github.com/GoogleCloudPlatform/cloud-builders/issues/435

3 个答案:

答案 0 :(得分:1)

如果使用github触发您的构建,由于缺少.git文件夹,它将无法正常工作。为了使其正常工作,所有存储库都必须由Cloud Source Repository进行镜像。然后,可以像这样更新子模块:

from tensorflow.keras.layers import Dense, Conv2D, Conv2DTranspose, Reshape, Flatten

... 

class Network:
    def __init__(self, params):
        weights_initializer = tf.initializers.GlorotUniform(seed=params["seed"])
        bias_initializer = tf.initializers.Constant(0.0)

        self.trainable_variables = []

        self.conv_layers = []
        self.conv_activations = []
        self.create_conv_layers(params, weights_initializer, bias_initializer)

        self.flatten_layer = Flatten()


        self.dense_layers = []
        self.dense_activations = []
        self.create_dense_layers(params, weights_initializer, bias_initializer)

        self.output_layer = Dense(1, kernel_initializer=weights_initializer, bias_initializer=bias_initializer)
        self.trainable_variables.append(self.output_layer.kernel)
        self.trainable_variables.append(self.output_layer.bias)

    def create_conv_layers(self, params, weight_init, bias_init):
        nconv = len(params['stride'])
        for i in range(nconv):
            conv_layer = Conv2D(filters=params["nfilter"][i],
                                kernel_size=params["shape"][i], kernel_initializer=weight_init,
                                kernel_regularizer=spectral_norm,
                                use_bias=True, bias_initializer=bias_init,
                                strides=params["stride"][i],
                                padding="same", )
            self.conv_layers.append(conv_layer)
            self.trainable_variables.append(conv_layer.kernel)
            self.trainable_variables.append(conv_layer.bias)
            self.conv_activations.append(params["activation"])

    def create_conv_layers(self, params, weight_init, bias_init):
        nconv = len(params['stride'])
        for i in range(nconv):
            conv_layer = Conv2D(filters=params["nfilter"][i],
                                kernel_size=params["shape"][i], kernel_initializer=weight_init,
                                kernel_regularizer=spectral_norm,
                                use_bias=True, bias_initializer=bias_init,
                                strides=params["stride"][i],
                                padding="same", )
            self.conv_layers.append(conv_layer)
            self.trainable_variables.append(conv_layer.kernel)
            self.trainable_variables.append(conv_layer.bias)
            self.conv_activations.append(params["activation"])

参考:https://github.com/GoogleCloudPlatform/cloud-builders/issues/26

答案 1 :(得分:0)

有时您会遇到GIT_DISCOVERY_ACROSS_FILESYSTEM或缺少的.git文件夹的错误。以下对我有用:

- id: git-submodule
  name: 'gcr.io/cloud-builders/git'
  entrypoint: 'bash'
  env: ['GIT_DISCOVERY_ACROSS_FILESYSTEM=1']
  args:
  - '-c'
  - |
    git init
    git config -f .gitmodules submodule.[my-sub-repo-name].url https://source.developers.google.com/p/[my-project]/r/github_[my-sub-repo-name]
    git submodule init
    git submodule update

答案 2 :(得分:0)

对于像我这样的人,他们在Bitbucket中使用子模块并在Cloud Build中遇到了类似的问题:一旦将存储库镜像到Cloud Source Repository,子模块URL将不允许具有.git扩展名。

例如,对于“子模块”文件夹中的主存储库https://source.cloud.google.com/Project_ID/main_repo和子模块a, b.gitmodules的配置可能与此类似

[submodule "submodules/a"]
    path = submodules/a
    url = ../a
[submodule "submodules/b"]
    path = submodules/b
    url = ../b

以前,我使用的URL ../a.git../b.git在Bitbucket中工作正常,但在Cloud Source Repository中工作不正常。