How do I specify a source in build requests using gcloud container builds submit?

1.6k Views Asked by At

I am trying to specify a build request with the source specified as a repoSource:

{                                                                                                                                                                                                         
    "source": {                                                                                                                                                                                           
        "repoSource": {                                                                                                                                                                                   
            "repoName": "myRepo",                                                                                                                                                                           
            "branchName": "master"                                                                                                                                                                        
        }                                                                                                                                                                                                 
    },                                                                                                                                                                                                    
    "steps": [                                                                                                                                                                                            
        {                                                                                                                                                                                                 
            "name": "gcr.io/cloud-builders/docker",                                                                                                                                                       
            "args": ["build", "-t", "gcr.io/$PROJECT_ID/zookeeper", "."]                                                                                                                                  
        }                                                                                                                                                                                                 
    ],                                                                                                                                                                                                    
    "images": [                                                                                                                                                                                           
        "gcr.io/$PROJECT_ID/zookeeper"                                                                                                                                                                    
    ]                                                                                                                                                                                                     
}

However, when I attempt to submit it with gcloud, I get an error:

$ gcloud container builds submit --no-source --config cloudbuild.json
ERROR: (gcloud.container.builds.submit) cloudbuild.json: config cannot specify source 

In "Writing Custom Build Requests" it says:

When you submit build requests using the gcloud command-line tool, the source field may not be necessary if you specify the source as a command-line argument. You may also specify a source in your build request file. See the gcloud documentation for more information.

Note: The storageSource and repoSource fields described in the Build resource documentation differ from the source field. storageSource instructs Container Builder to find the source files in a Cloud Storage bucket, and repoSource refers to a Cloud Source Repository containing the source files.

So how, then, do you specify repoSource with gcloud? I am only seeing the gs:// url prefix documented.

0

There are 0 best solutions below