diff --git a/cloudbuild.yaml b/cloudbuild.yaml index d5edf0c3..3815e498 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -20,4 +20,4 @@ steps: entrypoint: 'bash' args: ['-c', './integration_tests/run_tests_on_vm.sh'] -timeout: '20m' \ No newline at end of file +timeout: '20m' diff --git a/localbuilder_main.go b/localbuilder_main.go index 9e4a4dd7..ee9ddbd8 100644 --- a/localbuilder_main.go +++ b/localbuilder_main.go @@ -132,6 +132,14 @@ func run(source string) error { buildConfig.Substitutions = substMap } + // Get the ProjectId to feed both the build and the metadata server. + // This command uses a runner without dryrun to return the real project. + projectInfo, err := gcloud.ProjectInfo(&runner.RealRunner{}) + if err != nil { + return fmt.Errorf("Error getting project information from gcloud: %v", err) + } + buildConfig.ProjectId = projectInfo.ProjectID + // Validate the build. if err := validate.CheckBuild(buildConfig); err != nil { return fmt.Errorf("Error validating build: %v", err) @@ -180,11 +188,7 @@ func run(source string) error { metadataUpdater := metadata.RealUpdater{Local: true} defer metadataUpdater.Stop(r) - // Get project info to feed the metadata server. - projectInfo, err := gcloud.ProjectInfo(r) - if err != nil { - return fmt.Errorf("Error getting project information from gcloud: %v", err) - } + // Feed the project info to the metadata server. metadataUpdater.SetProjectInfo(projectInfo) go supplyTokenToMetadata(metadataUpdater, r)