5

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.

Community
  • 1
  • 1
Dmitry Minkovsky
  • 36,185
  • 26
  • 116
  • 160
  • 1
    This is not currently supported today. The gcloud surface only supports building from local source, which is uploaded to Cloud Storage and built from there as a `storageSource`, or using `--no-source` in which case no source is specified. – Jason Hall Jul 25 '17 at 16:08
  • Thanks @JasonHall. So I should use curl to submit a build request with a source? – Dmitry Minkovsky Jul 25 '17 at 16:16
  • Yeah, that's the best way today. – Jason Hall Jul 25 '17 at 16:31
  • The `gcloud` tool is great and it would be nice if I could use it. Is there a way I can feature request this? – Dmitry Minkovsky Oct 05 '17 at 20:16
  • For some alternatives, see https://stackoverflow.com/questions/48962597/triggering-a-build-for-a-specific-git-commit-via-gcloud-commandline-tool – Niel de Wet Jan 03 '19 at 13:46

0 Answers0