GoogleCloudPlatform/cloud-build-local

Error loading config file: unknown field "dynamic_substitutions" in cloudbuild.BuildOptions

kwladyka opened this issue ยท 9 comments

cloud-build-local is not compatible with gcloud builds. The issue is dynamic_substitutions.

Here is doc about dynamic_substitutions:
https://cloud.google.com/cloud-build/docs/configuring-builds/use-bash-and-bindings-in-substitutions

reproduce the issue:

cloudbuild.yaml

options:
  dynamic_substitutions: true
substitutions:
  _IMAGE_TAG: '${TAG_NAME:-latest}'
  _IMAGE: 'eu.gcr.io/${PROJECT_ID}/${REPO_NAME}:${_IMAGE_TAG}'
  _REVISION_SUFFIX_TAG: '${TAG_NAME//./-}'
  _REVISION_SUFFIX: '${_REVISION_SUFFIX_TAG:-${SHORT_SHA}}'
steps:
  - name: 'gcr.io/cloud-builders/gcloud'
    entrypoint: 'bash'
    args:
      - '-c'
      - 'echo _IMAGE_TAG $_IMAGE_TAG, _IMAGE $_IMAGE, _REVISION_SUFFIX_TAG $_REVISION_SUFFIX_TAG, _REVISION_SUFFIX $_REVISION_SUFFIX'
      - 'echo TAG_NAME $TAG_NAME, SHORT_SHA $SHORT_SHA, REPO_NAME $REPO_NAME'

run build locally and experience the issue:

cloud-build-local --substitutions=REPO_NAME=foo,SHORT_SHA=1234,TAG_NAME=v1.2.3 --dryrun=false .
2020/07/18 18:45:36 Error loading config file: unknown field "dynamic_substitutions" in cloudbuild.BuildOptions

expected result:

gcloud builds submit --no-source --substitutions=REPO_NAME=foo,SHORT_SHA=1234,TAG_NAME=v1.2.3 --config=cloudbuild.yaml
_IMAGE_TAG v1.2.3, _IMAGE eu.gcr.io/staging-redjar/foo:v1.2.3, _REVISION_SUFFIX_TAG v1-2-3, _REVISION_SUFFIX v1-2-3

PS There is also a bug in glcoud builds:
- 'echo TAG_NAME $TAG_NAME, SHORT_SHA $SHORT_SHA, REPO_NAME $REPO_NAME'

this line has to be added while it is useless because of

ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: invalid build: key "REPO_NAME" in the substitution data is not matched in the template;key "SHORT_SHA" in the substitution data is not matched in the template;key "TAG_NAME" in the substitution data is not matched in the template

which is not true, because this variables are used in substitutions. But not in steps. Not sure if this needs to be fixed in cloud-build-local separately from gcloud builds or report for gclod builds is enough.

I created the issue here for gcloud builds:
https://issuetracker.google.com/issues/161588167

I just tried the solution in the issuetracker for cloud-build-local posted in the issue tracker and it didn't work, still get the same error of "unknown field"

cloud-build-local --version
2021/02/24 14:33:09 Version: v0.5.2

In case anyone comes across this

It needs to be fixed. There is no way to "come across this".

any updates on this?

kpe commented

indeed, if the cloud-build-local tool does not allow to test locally before submitting to GCP (as it only supports a fraction of the features/schema), why does it exist at all?

any updates on this? also fails in local if you include pool attribute but also I found this in the documentation:

https://cloud.google.com/build/docs/build-debug-locally

Restrictions and limitations

The local builder can build on only Linux or macOS.
The local builder runs one build at a time on a given host. Running multiple builds in parallel will cause the local builder to fail.
The local builder does not support 100% feature parity with the hosted Cloud Build service. Examples of features not supported by the local builder include, but are not limited to the following:

  • Dynamic substitutions

  • Private pools

Any Plan to include this ones??????

someone had answered this on issuetracker

Hello,
The cloud build engineering team has gotten back to me in regards to your issue. simply adding the option [substitution_option: 'ALLOW_LOOSE'] should resolver your issue. if you have any other concerns or questions that are unrelated to this issue, please feel free to open another Public Issue.

I think we can close this issue

@confiq (https://issuetracker.google.com/issues/161588167) is different issue.

The github issue is about

2020/07/18 18:45:36 Error loading config file: unknown field "dynamic_substitutions" in cloudbuild.BuildOptions

which makes it behaving not the same as in gcloud. To be honest I don't use could-build-local from the time I created this issue and I didn't try again, because it is not 1:1 what gcloud. While I can't trust it I doesn't make sense to test using gcloud-local-build. Actually I wasn't even able to test the YAML file, because of the error above. In my case this tool is not useful, because I want to use dynamic_substitutions.

This might be a dead project. No commits for 17 months, and the last one was to add the message "The Cloud Build local builder is maintained at best effort"

Close Issue as part of archive process; please see notice of archive status.