Giter VIP home page Giter VIP logo

nodejs-cloudbuild's Introduction

THIS REPOSITORY IS DEPRECATED. ALL OF ITS CONTENT AND HISTORY HAS BEEN MOVED TO GOOGLE-CLOUD-NODE

Google Cloud Platform logo

release level npm version

Cloud Build API client for Node.js

A comprehensive list of changes in each version may be found in the CHANGELOG.

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Cloud Build API.
  4. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/cloudbuild

Using the client library

async function quickstart(
  projectId = 'YOUR_PROJECT_ID', // Your Google Cloud Platform project ID
  triggerId = 'YOUR_TRIGGER_ID', // UUID for build trigger.
  branchName = 'BRANCH_TO_BUILD' // Branch to run build against.
) {
  // Imports the Google Cloud client library
  const {CloudBuildClient} = require('@google-cloud/cloudbuild');

  // Creates a client
  const cb = new CloudBuildClient();

  // Note: for Private Pools, you'll have to specify an API endpoint value
  // For example:
  // const cb = new CloudBuildClient({ apiEndpoint: '<YOUR_POOL_REGION>-cloudbuild.googleapis.com' });

  // Starts a build against the branch provided.
  const [resp] = await cb.runBuildTrigger({
    projectId,
    triggerId,
    source: {
      projectId,
      dir: './',
      branchName,
    },
  });
  console.info(`triggered build for ${triggerId}`);
  const [build] = await resp.promise();

  const STATUS_LOOKUP = [
    'UNKNOWN',
    'Queued',
    'Working',
    'Success',
    'Failure',
    'Error',
    'Timeout',
    'Cancelled',
  ];
  for (const step of build.steps) {
    console.info(
      `step:
	name: ${step.name}
	status: ${STATUS_LOOKUP[build.status]}`
    );
  }
}

Using TypeScript

@google-cloud/cloudbuild provides TypeScript type definitions.

Samples

Samples are in the samples/ directory. Each sample's README.md has instructions for running its sample.

Sample Source Code Try it
List Triggers. source code Open in Cloud Shell
Quickstart source code Open in Cloud Shell

The Cloud Build Node.js Client API Reference documentation also contains samples.

Supported Node.js Versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js. If you are using an end-of-life version of Node.js, we recommend that you update as soon as possible to an actively supported LTS version.

Google's client libraries support legacy versions of Node.js runtimes on a best-efforts basis with the following warnings:

  • Legacy versions are not tested in continuous integration.
  • Some security patches and features cannot be backported.
  • Dependencies cannot be kept up-to-date.

Client libraries targeting some end-of-life versions of Node.js are available, and can be installed through npm dist-tags. The dist-tags follow the naming convention legacy-(version). For example, npm install @google-cloud/cloudbuild@legacy-8 installs client libraries for versions compatible with Node.js 8.

Versioning

This library follows Semantic Versioning.

This library is considered to be stable. The code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against stable libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

Please note that this README.md, the samples/README.md, and a variety of configuration files in this repository (including .nycrc and tsconfig.json) are generated from a central template. To edit one of these files, make an edit to its templates in directory.

License

Apache Version 2.0

See LICENSE

nodejs-cloudbuild's People

Contributors

alexander-fenster avatar bcoe avatar callmehiphop avatar chingor13 avatar dinagraves avatar donmccasland avatar fhinkel avatar gcf-merge-on-green[bot] avatar gcf-owl-bot[bot] avatar google-cloud-policy-bot[bot] avatar justinbeckwith avatar parthea avatar release-please[bot] avatar renovate-bot avatar sofisl avatar summer-ji-eng avatar surferjeffatgoogle avatar xiaozhenliu-gg5 avatar yoshi-automation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nodejs-cloudbuild's Issues

Synthesis failed for nodejs-cloudbuild

Hello! Autosynth couldn't regenerate nodejs-cloudbuild. ๐Ÿ’”

Here's the output from running synth.py:

oro/publish.sh
.kokoro/release/docs-devsite.cfg
.kokoro/release/docs-devsite.sh
.kokoro/release/docs.cfg
.kokoro/release/docs.sh
.kokoro/release/publish.cfg
.kokoro/samples-test.sh
.kokoro/system-test.sh
.kokoro/test.bat
.kokoro/test.sh
.kokoro/trampoline.sh
.kokoro/trampoline_v2.sh
.mocharc.js
.nycrc
.prettierignore
.prettierrc.js
.trampolinerc
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
api-extractor.json
renovate.json
samples/README.md
2020-11-17 01:07:47,042 synthtool [DEBUG] > Post-processing GAPIC library...
DEBUG:synthtool:Post-processing GAPIC library...
2020-11-17 01:07:47,042 synthtool [DEBUG] > Installing dependencies...
DEBUG:synthtool:Installing dependencies...

> [email protected] postinstall /home/kbuilder/.cache/synthtool/nodejs-cloudbuild/node_modules/protobufjs
> node scripts/postinstall


> @google-cloud/[email protected] prepare /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> npm run compile-protos && npm run compile


> @google-cloud/[email protected] compile-protos /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> compileProtos src

installing semver@^7.1.2
installing tmp@^0.2.0
installing uglify-js@^3.7.7
installing espree@^7.0.0
installing escodegen@^2.0.0
installing estraverse@^5.1.0

> @google-cloud/[email protected] precompile /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> gts clean

version: 14
Removing build ...

> @google-cloud/[email protected] compile /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> tsc -p . && cp -r protos build/

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 569 packages from 738 contributors and audited 570 packages in 27.183s

52 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

2020-11-17 01:08:14,829 synthtool [DEBUG] > Running prelint...
DEBUG:synthtool:Running prelint...

> @google-cloud/[email protected] prelint /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> cd samples; npm link ../; npm install


> @google-cloud/[email protected] prepare /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> npm run compile-protos && npm run compile


> @google-cloud/[email protected] compile-protos /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> compileProtos src


> @google-cloud/[email protected] precompile /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> gts clean

version: 14
Removing build ...

> @google-cloud/[email protected] compile /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> tsc -p . && cp -r protos build/

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 570 packages in 14.631s

52 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

/home/kbuilder/.nvm/versions/node/v14.15.1/lib/node_modules/@google-cloud/cloudbuild -> /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/samples/node_modules/@google-cloud/cloudbuild -> /home/kbuilder/.nvm/versions/node/v14.15.1/lib/node_modules/@google-cloud/cloudbuild -> /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 137 packages from 118 contributors and audited 225 packages in 4.472s

52 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

2020-11-17 01:08:35,700 synthtool [DEBUG] > Running fix...
DEBUG:synthtool:Running fix...

> @google-cloud/[email protected] fix /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> gts fix

version: 14

/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/src/v1/cloud_build_client.ts
  112:48  error  'window' is not defined  no-undef

โœ– 1 problem (1 error, 0 warnings)

Error: Command failed with exit code 1: node ./node_modules/eslint/bin/eslint --fix **/*.ts **/*.js **/*.tsx **/*.jsx --no-error-on-unmatched-pattern
    at makeError (/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/node_modules/execa/lib/error.js:59:11)
    at handlePromise (/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/node_modules/execa/index.js:114:26)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async run (/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/node_modules/gts/build/src/cli.js:120:17) {
  shortMessage: 'Command failed with exit code 1: node ./node_modules/eslint/bin/eslint --fix **/*.ts **/*.js **/*.tsx **/*.jsx --no-error-on-unmatched-pattern',
  command: 'node ./node_modules/eslint/bin/eslint --fix **/*.ts **/*.js **/*.tsx **/*.jsx --no-error-on-unmatched-pattern',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @google-cloud/[email protected] fix: `gts fix`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @google-cloud/[email protected] fix script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kbuilder/.npm/_logs/2020-11-17T09_08_47_412Z-debug.log
2020-11-17 01:08:47,420 synthtool [ERROR] > Failed executing npm run fix:

None
ERROR:synthtool:Failed executing npm run fix:

None
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
    main()
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
    spec.loader.exec_module(synth_module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/synth.py", line 39, in <module>
    node.postprocess_gapic_library()
  File "/tmpfs/src/github/synthtool/synthtool/languages/node.py", line 194, in postprocess_gapic_library
    fix(hide_output=hide_output)
  File "/tmpfs/src/github/synthtool/synthtool/languages/node.py", line 179, in fix
    shell.run(["npm", "run", "fix"], hide_output=hide_output)
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
    raise exc
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
    encoding="utf-8",
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['npm', 'run', 'fix']' returned non-zero exit status 1.
2020-11-17 01:08:47,486 autosynth [ERROR] > Synthesis failed
2020-11-17 01:08:47,487 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at ee0ae5d chore: release 2.0.5 (#182)
2020-11-17 01:08:47,516 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2020-11-17 01:08:47,536 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Removing build/
Removing node_modules/
Removing package-lock.json
Removing samples/node_modules/
Removing samples/package-lock.json
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 354, in <module>
    main()
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 189, in main
    return _inner_main(temp_dir)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 334, in _inner_main
    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 65, in synthesize_loop
    has_changes = toolbox.synthesize_version_in_new_branch(synthesizer, youngest)
  File "/tmpfs/src/github/synthtool/autosynth/synth_toolbox.py", line 259, in synthesize_version_in_new_branch
    synthesizer.synthesize(synth_log_path, self.environ)
  File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
    synth_proc.check_returncode()  # Raise an exception.
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.

Google internal developers can see the full log here.

Synthesis failed for nodejs-cloudbuild

Hello! Autosynth couldn't regenerate nodejs-cloudbuild. ๐Ÿ’”

Here's the output from running synth.py:

Cloning into 'working_repo'...
Switched to a new branch 'autosynth'
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/git/autosynth/autosynth/synth.py", line 482, in <module>
    main()
  File "/tmpfs/src/git/autosynth/autosynth/synth.py", line 334, in main
    return _inner_main(temp_dir)
  File "/tmpfs/src/git/autosynth/autosynth/synth.py", line 418, in _inner_main
    git_source.enumerate_versions(metadata["sources"], pathlib.Path(temp_dir))
KeyError: 'sources'

Google internal developers can see the full log here.

Integration Tests: should list triggers on project failed

This test failed!

To configure my behavior, see the Flaky Bot documentation.

If I'm commenting on this issue too often, add the flakybot: quiet label and
I will stop commenting.


commit: 004810d
buildURL: Build Status, Sponge
status: failed

Test output
16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Error: 16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
    at Object.callErrorFromStatus (node_modules/@grpc/grpc-js/build/src/call.js:31:19)
        -> /workspace/node_modules/@grpc/grpc-js/src/call.ts:81:17
    at Object.onReceiveStatus (node_modules/@grpc/grpc-js/build/src/client.js:190:52)
        -> /workspace/node_modules/@grpc/grpc-js/src/client.ts:352:36
    at Object.onReceiveStatus (node_modules/@grpc/grpc-js/build/src/client-interceptors.js:365:141)
        -> /workspace/node_modules/@grpc/grpc-js/src/client-interceptors.ts:462:34
    at Object.onReceiveStatus (node_modules/@grpc/grpc-js/build/src/client-interceptors.js:328:181)
        -> /workspace/node_modules/@grpc/grpc-js/src/client-interceptors.ts:424:48
    at /workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:188:78
        -> /workspace/node_modules/@grpc/grpc-js/src/call-stream.ts:330:24
    at processTicksAndRejections (internal/process/task_queues.js:79:11)
for call at
    at ServiceClientImpl.makeUnaryRequest (node_modules/@grpc/grpc-js/build/src/client.js:160:30)
        -> /workspace/node_modules/@grpc/grpc-js/src/client.ts:324:26
    at ServiceClientImpl. (node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
        -> /workspace/node_modules/@grpc/grpc-js/src/make-client.ts:189:15
    at /workspace/build/src/v1/cloud_build_client.js:283:29
        -> /workspace/src/v1/cloud_build_client.ts:439:25
    at wrappedCall (node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.js:86:20)
        -> /workspace/node_modules/google-gax/src/paginationCalls/pagedApiCaller.ts:107:15
    at /workspace/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16
        -> /workspace/node_modules/google-gax/src/normalCalls/timeout.ts:54:13
    at repeat (node_modules/google-gax/build/src/normalCalls/retries.js:80:25)
        -> /workspace/node_modules/google-gax/src/normalCalls/retries.ts:104:19
    at Immediate._onImmediate (node_modules/google-gax/build/src/normalCalls/retries.js:118:13)
        -> /workspace/node_modules/google-gax/src/normalCalls/retries.ts:144:7
    at processImmediate (internal/timers.js:463:21)

Support usage in Deno with ESM

Is your feature request related to a problem? Please describe.

I want to use this module in Deno however due to the package.json listing "browser": "src/browser.js", which is expected to be an ESM module and is unavailable Deno fails to import.

Describe the solution you'd like

Support ESM bundles properly

Describe alternatives you've considered

I have tried importing the compiled module from UNPKG at https://www.unpkg.com/browse/@google-cloud/[email protected]/ however Deno fails to resolve the exports here as well.

runBuildTrigger does not include location as part of trigger path

Environment details

  • OS: Mac
  • Node.js version:16.14.2
  • npm version:
  • @google-cloud/cloudbuild version:^3.0.0

Steps to reproduce

Call method runBuildTrigger(), passing in the project Id and Trigger Id

const cb = new CloudBuildClient();
const [resp] = await cb.runBuildTrigger({
projectId,
triggerId
});
const [build] = await resp.promise();

Returns Error: 5 NOT_FOUND: triggerError spanner trigger ([project number], [triggerId]) not found

In searching the logs, the resource name passed in the API request is projects/[projectId]/triggers/[triggerId]

The actual resource name should be projects/[projectId]/locations/[location]/triggers/[triggerId]

The client library does include the location as a part of the resource name, so it does not find the trigger

listBuilds with filter throws INVALID_ARGUMENT: Request contains an invalid argument

I have a cloudfunction triggered by cloudbuilds. the purpouse of function is to cancel running builds from same branch and trigger.
filter argument does not work and has no proper documentation

Environment details

  • OS: gc cloudfunctions
  • Node.js version: 14
  • yarn version: 1.22.17
  • @google-cloud/cloudbuild version: 2.6.0

Steps to reproduce

const { CloudBuildClient } = require('@google-cloud/cloudbuild');

const parseBuild = (data) => JSON.parse(Buffer.from(data, "base64").toString());

module.exports["gcb-canceler"] = async (buildStream) => {
  const parsedBuild = parseBuild(buildStream.data);
  const buildStatus = parsedBuild.status;

  const buildTriggerId = parsedBuild.buildTriggerId;
  const buildId = parsedBuild.id;
  const projectId = parsedBuild.projectId
  const targetBranch = parsedBuild.substitutions.BRANCH_NAME

  if (buildStatus === `QUEUED` && buildId && targetBranch && buildTriggerId) {
    const cb = new CloudBuildClient();

    const filter = `id!="${buildId}" AND substitutions.BRANCH_NAME="${targetBranch}" AND buildTriggerId="${buildTriggerId}" AND status<=2`;
    
    console.log(filter);

    const request = {
      projectId,
      filter
    };

    const [builds] = await cb.listBuilds(request)
  }
}

throws INVALID_ARGUMENT. filter expression is correct as I test it by running gcloud builds list --filter="EXPRESSION" and it returns me list of builds.

Thanks!

User substitution variables aren't applying

I'm experiencing an issue where attempting to provide user substitution variables via substitutions property of a RepoSource object passed via runBuildTrigger is not reflected in my build steps.

Environment details

  • OS: GCF, HTTP Trigger
  • Node.js version: 10
  • npm version: Unknown
  • @google-cloud/cloudbuild version: 1.5.0

Steps to reproduce

  1. Have a Google Cloud Build trigger with a few user substitution variables added
  2. Declare an object of substitutions following the naming convention (e.g. _MY_SUB_VAR)
  3. Review your GCB Build Log, both in a bash log and execution details tab, default values under "User substitutions" are still present; my provided substitutions are ignored

Of note, when breaking the naming convention (omitting the _ prefix), the build does fail due to GCB validation; so the object is being sent in the request, and appears under "Built-in substitutions" in the build log; when using the proper naming convention, they do not map over the defaults.

Annotation 2020-05-12 195521

Redacted Code Snippet of runBuildTrigger invocation

gcb.runBuildTrigger(
    {
        projectId: "...",
        triggerId: "...",
        source: {
            projectId: "...",
            branchName: targetBranchOrTag,
            substitutions: {
                _APP_BASE_SERVICE_URI: `https://${targetBucket[0].name}`,
                _RS_BASE_SERVICE_URI: `https://.../${targetBranchOrTag}`,
                _TARGET_BUCKET: targetBucket[0].name,
            },
        },
    },
...

Any guidance or assistance in resolving this matter is appreciated.

gcr.io/cloud-builders/npm:node-10.10.0 container fails running our tests

Our test suite fails to run on cloudbuild's npm containers, potential reasons:

  • inspector might not be compiled with the version of Node.js that runs on gcr.io/cloud-builders/npm, this would be good to fix.
  • 10.10.0 is a fairly old version of Node.js, 10.16.3 is the current stable, 12 goes LTS soon.

It would be nice to be able to dog-food cloudbuild, as part of our testing process in this repo.

Synthesis failed for nodejs-cloudbuild

Hello! Autosynth couldn't regenerate nodejs-cloudbuild. ๐Ÿ’”

Here's the output from running synth.py:

Cloning into 'working_repo'...
Switched to branch 'autosynth'
Running synthtool
['/tmpfs/src/git/autosynth/env/bin/python3', '-m', 'synthtool', 'synth.py', '--']
synthtool > Executing /tmpfs/src/git/autosynth/working_repo/synth.py.
synthtool > Ensuring dependencies.
synthtool > Cloning googleapis.
synthtool > Pulling Docker image: gapic-generator-typescript:latest
latest: Pulling from gapic-images/gapic-generator-typescript
e7c96db7181b: Pulling fs layer
244f3e558d53: Pulling fs layer
56f1db5978c9: Pulling fs layer
ea135e98c1eb: Pulling fs layer
2348c943abee: Pulling fs layer
011a4cea9dab: Pulling fs layer
eca92ae992ea: Pulling fs layer
51c92ed7f5bf: Pulling fs layer
727d8b6e1b4b: Pulling fs layer
7aad056dfc7a: Pulling fs layer
ba0ace3a7d65: Pulling fs layer
93e3488a034a: Pulling fs layer
0f03aeb58393: Pulling fs layer
8b6e8c6a46bd: Pulling fs layer
2808e876deea: Pulling fs layer
64dc8796efe8: Pulling fs layer
42bf34f40b44: Pulling fs layer
7acef19e31be: Pulling fs layer
57739d5781f0: Pulling fs layer
ea135e98c1eb: Waiting
2348c943abee: Waiting
011a4cea9dab: Waiting
eca92ae992ea: Waiting
51c92ed7f5bf: Waiting
727d8b6e1b4b: Waiting
7aad056dfc7a: Waiting
ba0ace3a7d65: Waiting
93e3488a034a: Waiting
0f03aeb58393: Waiting
8b6e8c6a46bd: Waiting
2808e876deea: Waiting
64dc8796efe8: Waiting
42bf34f40b44: Waiting
7acef19e31be: Waiting
57739d5781f0: Waiting
e7c96db7181b: Download complete
56f1db5978c9: Verifying Checksum
56f1db5978c9: Download complete
ea135e98c1eb: Download complete
e7c96db7181b: Pull complete
2348c943abee: Download complete
011a4cea9dab: Verifying Checksum
011a4cea9dab: Download complete
244f3e558d53: Verifying Checksum
244f3e558d53: Download complete
eca92ae992ea: Verifying Checksum
eca92ae992ea: Download complete
51c92ed7f5bf: Verifying Checksum
51c92ed7f5bf: Download complete
727d8b6e1b4b: Verifying Checksum
727d8b6e1b4b: Download complete
ba0ace3a7d65: Download complete
7aad056dfc7a: Verifying Checksum
7aad056dfc7a: Download complete
93e3488a034a: Verifying Checksum
93e3488a034a: Download complete
8b6e8c6a46bd: Verifying Checksum
8b6e8c6a46bd: Download complete
0f03aeb58393: Verifying Checksum
0f03aeb58393: Download complete
2808e876deea: Verifying Checksum
2808e876deea: Download complete
64dc8796efe8: Verifying Checksum
64dc8796efe8: Download complete
42bf34f40b44: Download complete
57739d5781f0: Verifying Checksum
57739d5781f0: Download complete
7acef19e31be: Verifying Checksum
7acef19e31be: Download complete
244f3e558d53: Pull complete
56f1db5978c9: Pull complete
ea135e98c1eb: Pull complete
2348c943abee: Pull complete
011a4cea9dab: Pull complete
eca92ae992ea: Pull complete
51c92ed7f5bf: Pull complete
727d8b6e1b4b: Pull complete
7aad056dfc7a: Pull complete
ba0ace3a7d65: Pull complete
93e3488a034a: Pull complete
0f03aeb58393: Pull complete
8b6e8c6a46bd: Pull complete
2808e876deea: Pull complete
64dc8796efe8: Pull complete
42bf34f40b44: Pull complete
7acef19e31be: Pull complete
57739d5781f0: Pull complete
Digest: sha256:a7f89dbac851b1daf372db435f555fcbd77551a66bfb6ea3a21457e616be156d
Status: Downloaded newer image for gcr.io/gapic-images/gapic-generator-typescript:latest
synthtool > Generating code for: google/devtools/cloudbuild/v1.
synthtool > Failed executing docker run --mount type=bind,source=/home/kbuilder/.cache/synthtool/googleapis/google/devtools/cloudbuild/v1/,destination=/in/google/devtools/cloudbuild/v1/,readonly --mount type=bind,source=/tmpfs/tmp/tmp3qua4out/,destination=/out/ --rm --user kbuilder gcr.io/gapic-images/gapic-generator-typescript:latest --grpc-service-config google/devtools/cloudbuild/v1/cloudbuild_grpc_service_config.json:

docker: Error response from daemon: linux spec user: unable to find user kbuilder: no matching entries in passwd file.

Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.1/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.1/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/git/autosynth/env/lib/python3.6/site-packages/synthtool/__main__.py", line 87, in <module>
    main()
  File "/tmpfs/src/git/autosynth/env/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/tmpfs/src/git/autosynth/env/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/tmpfs/src/git/autosynth/env/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmpfs/src/git/autosynth/env/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/tmpfs/src/git/autosynth/env/lib/python3.6/site-packages/synthtool/__main__.py", line 79, in main
    spec.loader.exec_module(synth_module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/tmpfs/src/git/autosynth/working_repo/synth.py", line 33, in <module>
    version=version)
  File "/tmpfs/src/git/autosynth/env/lib/python3.6/site-packages/synthtool/gcp/gapic_microgenerator.py", line 65, in typescript_library
    return self._generate_code(service, version, "typescript", **kwargs)
  File "/tmpfs/src/git/autosynth/env/lib/python3.6/site-packages/synthtool/gcp/gapic_microgenerator.py", line 182, in _generate_code
    shell.run(docker_run_args)
  File "/tmpfs/src/git/autosynth/env/lib/python3.6/site-packages/synthtool/shell.py", line 39, in run
    raise exc
  File "/tmpfs/src/git/autosynth/env/lib/python3.6/site-packages/synthtool/shell.py", line 33, in run
    encoding="utf-8",
  File "/home/kbuilder/.pyenv/versions/3.6.1/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['docker', 'run', '--mount', 'type=bind,source=/home/kbuilder/.cache/synthtool/googleapis/google/devtools/cloudbuild/v1/,destination=/in/google/devtools/cloudbuild/v1/,readonly', '--mount', 'type=bind,source=/tmpfs/tmp/tmp3qua4out/,destination=/out/', '--rm', '--user', 'kbuilder', 'gcr.io/gapic-images/gapic-generator-typescript:latest', '--grpc-service-config', 'google/devtools/cloudbuild/v1/cloudbuild_grpc_service_config.json']' returned non-zero exit status 125.
synthtool > Cleaned up 0 temporary directories.
synthtool > Wrote metadata to synth.metadata.

Synthesis failed

Google internal developers can see the full log here.

await runBuildTrigger() should return a promise

currently await runBuildTrigger() returns a raw object, indicative of a long running operation, it should instead return a long running operation, so that folks can await a build completion.

Documentation: Mocking/Stubbing certain functions requires stubbing parts of `google-gax`

Is your feature request related to a problem? Please describe.

Recently when writing some integration tests for my code I needed to stub the createBuild function. To do this effectively I also needed to stub the OperationsClient that is returned for long-running operations since that is then used to check the result of the request.

After combing through the source code for this library I figured out that the operations client comes from the google-gax dependency.

Describe the solution you'd like

I think it would be great to document some examples of how to mock/stub this library (when using something like sinon) just to make it easier for folks to know how to test around this library and its dependency on gax/grpc. I'd be happy to contribute some of my own examples.

Synthesis failed for nodejs-cloudbuild

Hello! Autosynth couldn't regenerate nodejs-cloudbuild. ๐Ÿ’”

Here's the output from running synth.py:

ux1_x86_64.whl (1.3MB)
  Saved ./protobuf-3.13.0-cp36-cp36m-manylinux1_x86_64.whl
Collecting pypandoc==1.5 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 7))
  Downloading https://files.pythonhosted.org/packages/d6/b7/5050dc1769c8a93d3ec7c4bd55be161991c94b8b235f88bf7c764449e708/pypandoc-1.5.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmpfs/tmp/tmp0lzxv2_5/setuptools-tmp/setuptools/__init__.py", line 6, in <module>
        import distutils.core
      File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/_distutils_hack/__init__.py", line 82, in create_module
        return importlib.import_module('._distutils', 'setuptools')
      File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ModuleNotFoundError: No module named 'setuptools._distutils'
    
    ----------------------------------------
 (  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
Command "python setup.py egg_info" failed with error code 1 in /tmpfs/tmp/pip-build-l4z4a8op/pypandoc/
)
ERROR: no such package '@gapic_generator_python_pip_deps//': pip_import failed: Collecting click==7.1.2 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl (82kB)
  Saved ./click-7.1.2-py2.py3-none-any.whl
Collecting google-api-core==1.22.1 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 2))
  Downloading https://files.pythonhosted.org/packages/e0/2d/7c6c75013105e1d2b6eaa1bf18a56995be1dbc673c38885aea31136e9918/google_api_core-1.22.1-py2.py3-none-any.whl (91kB)
  Saved ./google_api_core-1.22.1-py2.py3-none-any.whl
Collecting googleapis-common-protos==1.52.0 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 3))
  Downloading https://files.pythonhosted.org/packages/03/74/3956721ea1eb4bcf7502a311fdaa60b85bd751de4e57d1943afe9b334141/googleapis_common_protos-1.52.0-py2.py3-none-any.whl (100kB)
  Saved ./googleapis_common_protos-1.52.0-py2.py3-none-any.whl
Collecting jinja2==2.11.2 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 4))
  Downloading https://files.pythonhosted.org/packages/30/9e/f663a2aa66a09d838042ae1a2c5659828bb9b41ea3a6efa20a20fd92b121/Jinja2-2.11.2-py2.py3-none-any.whl (125kB)
  Saved ./Jinja2-2.11.2-py2.py3-none-any.whl
Collecting MarkupSafe==1.1.1 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 5))
  Downloading https://files.pythonhosted.org/packages/b2/5f/23e0023be6bb885d00ffbefad2942bc51a620328ee910f64abe5a8d18dd1/MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
  Saved ./MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Collecting protobuf==3.13.0 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 6))
  Downloading https://files.pythonhosted.org/packages/30/79/510974552cebff2ba04038544799450defe75e96ea5f1675dbf72cc8744f/protobuf-3.13.0-cp36-cp36m-manylinux1_x86_64.whl (1.3MB)
  Saved ./protobuf-3.13.0-cp36-cp36m-manylinux1_x86_64.whl
Collecting pypandoc==1.5 (from -r /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_python/requirements.txt (line 7))
  Downloading https://files.pythonhosted.org/packages/d6/b7/5050dc1769c8a93d3ec7c4bd55be161991c94b8b235f88bf7c764449e708/pypandoc-1.5.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmpfs/tmp/tmp0lzxv2_5/setuptools-tmp/setuptools/__init__.py", line 6, in <module>
        import distutils.core
      File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/_distutils_hack/__init__.py", line 82, in create_module
        return importlib.import_module('._distutils', 'setuptools')
      File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    ModuleNotFoundError: No module named 'setuptools._distutils'
    
    ----------------------------------------
 (  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
Command "python setup.py egg_info" failed with error code 1 in /tmpfs/tmp/pip-build-l4z4a8op/pypandoc/
)
INFO: Elapsed time: 20.898s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)

Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
    main()
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
    spec.loader.exec_module(synth_module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/synth.py", line 30, in <module>
    library = gapic.node_library('devtools-cloudbuild', version, proto_path='google/devtools/cloudbuild/v1')
  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 52, in node_library
    return self._generate_code(service, version, "nodejs", **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 183, in _generate_code
    shell.run(bazel_run_args)
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
    raise exc
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
    encoding="utf-8",
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['bazel', '--max_idle_secs=240', 'build', '//google/devtools/cloudbuild/v1:devtools-cloudbuild-v1-nodejs']' returned non-zero exit status 1.
2020-08-31 01:02:30,930 autosynth [ERROR] > Synthesis failed
2020-08-31 01:02:30,930 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at 956c248 build: track flaky tests for "nightly", add new secrets for tagging (#160)
2020-08-31 01:02:30,935 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2020-08-31 01:02:30,939 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 690, in <module>
    main()
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 539, in main
    return _inner_main(temp_dir)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 670, in _inner_main
    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 375, in synthesize_loop
    has_changes = toolbox.synthesize_version_in_new_branch(synthesizer, youngest)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 273, in synthesize_version_in_new_branch
    synthesizer.synthesize(synth_log_path, self.environ)
  File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
    synth_proc.check_returncode()  # Raise an exception.
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.

Google internal developers can see the full log here.

Create a build trigger connected to a GitHub repository through the API

Hello,

We are currently trying to develop an infrastructure with Google Cloud.

One of the problem we are trying to solve is to avoid repeating 100 times some basic CI/CD configurations for our microservices.

So I try to create build triggers through the API and I hurt a problem that I understand, but cannot solve:

UnhandledPromiseRejectionWarning: Error: 9 FAILED_PRECONDITION: Repository mapping does not exist.
Please visit https://console.cloud.google.com/cloud-build/triggers/connect?project=21725486103
to connect a repository to your project.

My double checks:

  • The GitHub's Cloud Build app is properly installed.
  • The GitHub's Cloud Build app is properly configured for all repositories.
  • Google Cloud Run is properly connected to GitHub and works well when a trigger is created manually.
  • I can't even create a trigger on an already connect repository that already have a trigger.

Here is my request done with the Node.js client:

const [resp] = await cloudBuild.createBuildTrigger({
  projectId: 'super-top-secret',
  trigger: {
    name: 'test-automation',
    github: {
      installationId: 0123456789,
      owner: 'our-not-so-secret-company',
      repo: 'test-nodejs-ci',
      push: {
        branch: '.*',
      },
    }
  },
});

Maybe I missed something? My fear is that is simply not possible.

Maybe a problem with the service account used for the API call ?

Can you help me?

Thank you!

How to use authentication passing credentials using code.

Hi guy,

I see HERE

// Imports the Google Cloud client library.
const {Storage} = require('@google-cloud/storage');

// Instantiates a client. Explicitly use service account credentials by
// specifying the private key file. All clients in google-cloud-node have this
// helper, see https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/docs/authentication.md
// const projectId = 'project-id'
// const keyFilename = '/path/to/keyfile.json'
const storage = new Storage({projectId, keyFilename});

// Makes an authenticated API request.
async function listBuckets() {
  try {
    const [buckets] = await storage.getBuckets();

    console.log('Buckets:');
    buckets.forEach((bucket) => {
      console.log(bucket.name);
    });
  } catch (err) {
    console.error('ERROR:', err);
  }
}
listBuckets();

With CloudBuildClient Document
image

When I use this for my code:
image

I has error
image

But when i use google-auth-library => It's work.
image

Please help!!!

Sample Integration Tests: should run list-build-triggers.js failed

This test failed!

To configure my behavior, see the Flaky Bot documentation.

If I'm commenting on this issue too often, add the flakybot: quiet label and
I will stop commenting.


commit: 004810d
buildURL: Build Status, Sponge
status: failed

Test output
expected '' to include 'Push-to-any-branch'
AssertionError: expected '' to include 'Push-to-any-branch'
    at Context. (system-test/samples.js:47:12)
    at processImmediate (internal/timers.js:461:21)

Cannot get metadata of build right after creation but before completion

Environment details

  • OS: Ubuntu 18
  • Node.js version: 10.16.0
  • npm version: 6.14.2
  • @google-cloud/cloudbuild version: 1.5.0

Steps to reproduce

  1. I need to get metadata details of a cloud build run (such as cloud build id) right after the creation, the sample only shows a basic example of creating a build and waiting for it to finish before being able to inspect the object. From the typescript definitions alone it's not clear how you can get access to cloud build id or such after its creation without. See code below
import { CloudBuildClient } from '@google-cloud/cloudbuild';

const gcb = new CloudBuildClient();
const [resp] = await gcb.runBuildTrigger({
    projectId: 'something',
    triggerId: 'something',
    source: {
      projectId: 'something',
      tagName: 'something',
    },
  });

  // I need to get cloud build id from "resp", yet nothing in the typescript definitions suggest how this is possible.

  const [build] = await resp.promise();
  // I can get metadata easily from "build", but this is after the build has finished, too late for my purposes

Thanks,
Victor

Unable to create build with custom pool

I used the sample code to try triggering a cloud build from a config file. Things worked when without the worker pool parameter. I got a worker pool not found error. I could send build to the worker pool with cli but just not nodejs. I actually tried the REST API and Python SDK but also didn't work.

(node:631727) UnhandledPromiseRejectionWarning: Error: 5 NOT_FOUND: workerpool not found: "projects/<project id>/workerPools/<worker pool name>"
    at Object.callErrorFromStatus (/home/michael/project1/node_modules/@grpc/grpc-js/build/src/call.js:31:26)
    at Object.onReceiveStatus (/home/michael/project1/node_modules/@grpc/grpc-js/build/src/client.js:180:52)
    at Object.onReceiveStatus (/home/michael/project1/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:365:141)
    at Object.onReceiveStatus (/home/michael/project1/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:328:181)
    at /home/michael/project1/node_modules/@grpc/grpc-js/build/src/call-stream.js:182:78
    at processTicksAndRejections (internal/process/task_queues.js:79:11)

Environment details

  • OS: Ubuntu 21.04
  • Node.js version: v12.21.0
  • npm version: 7.5.2
  • @google-cloud/cloudbuild version: 2.6.0

Steps to reproduce

import json

import google.auth
from google.cloud.devtools import cloudbuild_v1

def quickstart():
    """Create and execute a simple Google Cloud Build configuration,
    print the in-progress status and print the completed status."""

    # Authorize the client with Google defaults
    credentials, project_id = google.auth.default()
    client = cloudbuild_v1.services.cloud_build.CloudBuildClient()

    build = cloudbuild_v1.Build()

    # The following build steps will output "hello world"
    # For more information on build configuration, see
    # https://cloud.google.com/build/docs/configuring-builds/create-basic-configuration
    j = json.loads(open('cloudbuild.json').read())
    build.steps = j['steps']
    build.substitutions = j['substitutions']
    build.images = j['images']
    build.options = {"pool": {"name":j['workerPool']}}
    # build.timeout = 3000 # j['timeout']

    operation = client.create_build(project_id='<project id>', build=build)
    # Print the in-progress operation
    print("IN PROGRESS:")
    print(operation.metadata)

    result = operation.result()
    # Print the completed status
    print("RESULT:", result.status)
# [END cloudbuild_quickstart]


if __name__ == "__main__":
    quickstart()

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Synthesis failed for nodejs-cloudbuild

Hello! Autosynth couldn't regenerate nodejs-cloudbuild. ๐Ÿ’”

Here's the output from running synth.py:

t a canonical reproducible form can be obtained by modifying arguments sha256 = "8d11f06b408ac5f1c01da3ca17f3a75dc008831509c5c1a4f24f9bde37792a57"
DEBUG: Call stack for the definition of repository 'gapic_generator_python' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
 - <builtin>
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:224:1
DEBUG: Rule 'com_googleapis_gapic_generator_go' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "12bfed7873f085093cd60615bd113178ecf36396af0c2ca25e6cd4d4bebdd198"
DEBUG: Call stack for the definition of repository 'com_googleapis_gapic_generator_go' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
 - <builtin>
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:261:1
DEBUG: Rule 'gapic_generator_typescript' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "ca322b5e7b0d03b3cc44a90444e3a7f944c9ba3345f0505ee48c8e715d19dd95"
DEBUG: Call stack for the definition of repository 'gapic_generator_typescript' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
 - <builtin>
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:280:1
DEBUG: Rule 'gapic_generator_csharp' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "40ddae63d2729ef5ccbd8b60123327ea200ce9400d0629238193ff530dcaea18"
DEBUG: Call stack for the definition of repository 'gapic_generator_csharp' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
 - <builtin>
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:318:1
DEBUG: Rule 'bazel_skylib' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "1dde365491125a3db70731e25658dfdd3bc5dbdfd11b840b3e987ecf043c7ca0"
DEBUG: Call stack for the definition of repository 'bazel_skylib' which is a http_archive (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):
 - <builtin>
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:35:1
Analyzing: target //google/devtools/cloudbuild/v1:devtools-cloudbuild-v1-nodejs (1 packages loaded, 0 targets configured)
INFO: Call stack for the definition of repository 'npm' which is a yarn_install (rule definition at /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl:411:16):
 - <builtin>
 - /home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/build_bazel_rules_nodejs/index.bzl:87:5
 - /home/kbuilder/.cache/synthtool/googleapis/WORKSPACE:293:1
Analyzing: target //google/devtools/cloudbuild/v1:devtools-cloudbuild-v1-nodejs (1 packages loaded, 3 targets configured)
ERROR: An error occurred during the fetch of repository 'npm':
   yarn_install failed: yarn install v1.19.1
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info If you think this is a bug, please open a bug report with the information provided in "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_typescript/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
 (error An unexpected error occurred: "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz: Request failed \"404 Not Found\"".
)
ERROR: /home/kbuilder/.cache/synthtool/googleapis/google/devtools/cloudbuild/v1/BUILD.bazel:225:1: //google/devtools/cloudbuild/v1:cloudbuild_nodejs_gapic depends on @gapic_generator_typescript//:protoc_plugin in repository @gapic_generator_typescript which failed to fetch. no such package '@npm//@bazel/typescript': yarn_install failed: yarn install v1.19.1
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info If you think this is a bug, please open a bug report with the information provided in "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_typescript/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
 (error An unexpected error occurred: "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz: Request failed \"404 Not Found\"".
)
ERROR: Analysis of target '//google/devtools/cloudbuild/v1:devtools-cloudbuild-v1-nodejs' failed; build aborted: no such package '@npm//@bazel/typescript': yarn_install failed: yarn install v1.19.1
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info If you think this is a bug, please open a bug report with the information provided in "/home/kbuilder/.cache/bazel/_bazel_kbuilder/a732f932c2cbeb7e37e1543f189a2a73/external/gapic_generator_typescript/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
 (error An unexpected error occurred: "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz: Request failed \"404 Not Found\"".
)
INFO: Elapsed time: 1.291s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 3 targets configured)
FAILED: Build did NOT complete successfully (1 packages loaded, 3 targets configured)

2020-08-06 04:12:53,834 synthtool [DEBUG] > Wrote metadata to synth.metadata.
DEBUG:synthtool:Wrote metadata to synth.metadata.
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
    main()
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
    spec.loader.exec_module(synth_module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/synth.py", line 30, in <module>
    library = gapic.node_library('devtools-cloudbuild', version, proto_path='google/devtools/cloudbuild/v1')
  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 52, in node_library
    return self._generate_code(service, version, "nodejs", **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_bazel.py", line 183, in _generate_code
    shell.run(bazel_run_args)
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
    raise exc
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
    encoding="utf-8",
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['bazel', '--max_idle_secs=240', 'build', '//google/devtools/cloudbuild/v1:devtools-cloudbuild-v1-nodejs']' returned non-zero exit status 1.
2020-08-06 04:12:53,901 autosynth [ERROR] > Synthesis failed
2020-08-06 04:12:53,901 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at f36b9fe docs: update worker pool path comment (#151)
2020-08-06 04:12:53,908 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2020-08-06 04:12:53,914 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 690, in <module>
    main()
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 539, in main
    return _inner_main(temp_dir)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 670, in _inner_main
    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 375, in synthesize_loop
    has_changes = toolbox.synthesize_version_in_new_branch(synthesizer, youngest)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 273, in synthesize_version_in_new_branch
    synthesizer.synthesize(synth_log_path, self.environ)
  File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
    synth_proc.check_returncode()  # Raise an exception.
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.

Google internal developers can see the full log here.

Synthesis failed for nodejs-cloudbuild

Hello! Autosynth couldn't regenerate nodejs-cloudbuild. ๐Ÿ’”

Here's the output from running synth.py:

Cloning into 'working_repo'...
Switched to branch 'autosynth'
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.1/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.1/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/git/autosynth/autosynth/synth.py", line 256, in <module>
    main()
  File "/tmpfs/src/git/autosynth/autosynth/synth.py", line 196, in main
    last_synth_commit_hash = get_last_metadata_commit(args.metadata_path)
  File "/tmpfs/src/git/autosynth/autosynth/synth.py", line 149, in get_last_metadata_commit
    text=True,
  File "/home/kbuilder/.pyenv/versions/3.6.1/lib/python3.6/subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'text'

Google internal developers can see the full log here.

Synthesis failed for nodejs-cloudbuild

Hello! Autosynth couldn't regenerate nodejs-cloudbuild. ๐Ÿ’”

Here's the output from running synth.py:

-']
2021-01-07 01:11:48,655 autosynth [DEBUG] > log_file_path: /tmpfs/src/logs/nodejs-cloudbuild/95/sponge_log.log
2021-01-07 01:11:48,657 autosynth [DEBUG] > Running: /tmpfs/src/github/synthtool/env/bin/python3 -m synthtool --metadata synth.metadata synth.py --
2021-01-07 01:11:48,899 synthtool [DEBUG] > Executing /home/kbuilder/.cache/synthtool/nodejs-cloudbuild/synth.py.
On branch autosynth-95
nothing to commit, working tree clean
2021-01-07 01:11:49,031 synthtool [DEBUG] > Ensuring dependencies.
DEBUG:synthtool:Ensuring dependencies.
2021-01-07 01:11:49,041 synthtool [DEBUG] > Cloning googleapis.
DEBUG:synthtool:Cloning googleapis.
2021-01-07 01:11:49,042 synthtool [DEBUG] > Using precloned repo /home/kbuilder/.cache/synthtool/googleapis
DEBUG:synthtool:Using precloned repo /home/kbuilder/.cache/synthtool/googleapis
2021-01-07 01:11:49,047 synthtool [DEBUG] > Generating code for: //google/devtools/cloudbuild/v1:devtools-cloudbuild-v1-nodejs.
DEBUG:synthtool:Generating code for: //google/devtools/cloudbuild/v1:devtools-cloudbuild-v1-nodejs.
2021-01-07 01:12:16,540 synthtool [SUCCESS] > Generated code into /tmpfs/tmp/tmpp50y97t1.
SUCCESS:synthtool:Generated code into /tmpfs/tmp/tmpp50y97t1.
2021-01-07 01:12:16,551 synthtool [DEBUG] > Using precloned repo /home/kbuilder/.cache/synthtool/synthtool
DEBUG:synthtool:Using precloned repo /home/kbuilder/.cache/synthtool/synthtool
2021-01-07 01:12:16,572 synthtool [INFO] > successfully generate `src/index.ts`
INFO:synthtool:successfully generate `src/index.ts`
.eslintignore
.eslintrc.json
.gitattributes
.github/ISSUE_TEMPLATE/bug_report.md
.github/ISSUE_TEMPLATE/feature_request.md
.github/ISSUE_TEMPLATE/support_request.md
.github/PULL_REQUEST_TEMPLATE.md
.github/release-please.yml
.github/workflows/ci.yaml
.kokoro/.gitattributes
.kokoro/common.cfg
.kokoro/continuous/node10/common.cfg
.kokoro/continuous/node10/docs.cfg
.kokoro/continuous/node10/test.cfg
.kokoro/continuous/node12/common.cfg
.kokoro/continuous/node12/lint.cfg
.kokoro/continuous/node12/samples-test.cfg
.kokoro/continuous/node12/system-test.cfg
.kokoro/continuous/node12/test.cfg
.kokoro/docs.sh
.kokoro/lint.sh
.kokoro/populate-secrets.sh
.kokoro/presubmit/node10/common.cfg
.kokoro/presubmit/node12/common.cfg
.kokoro/presubmit/node12/samples-test.cfg
.kokoro/presubmit/node12/system-test.cfg
.kokoro/presubmit/node12/test.cfg
.kokoro/publish.sh
.kokoro/release/docs-devsite.cfg
.kokoro/release/docs-devsite.sh
.kokoro/release/docs.cfg
.kokoro/release/docs.sh
.kokoro/release/publish.cfg
.kokoro/samples-test.sh
.kokoro/system-test.sh
.kokoro/test.bat
.kokoro/test.sh
.kokoro/trampoline.sh
.kokoro/trampoline_v2.sh
.mocharc.js
.nycrc
.prettierignore
.prettierrc.js
.trampolinerc
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
api-extractor.json
renovate.json
samples/README.md
2021-01-07 01:12:16,696 synthtool [DEBUG] > Post-processing GAPIC library...
DEBUG:synthtool:Post-processing GAPIC library...
2021-01-07 01:12:16,697 synthtool [DEBUG] > Installing dependencies...
DEBUG:synthtool:Installing dependencies...
npm WARN deprecated [email protected]: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated [email protected]: Use cheerio-select instead
npm WARN deprecated [email protected]: "Please update to latest v2.3 or v2.2"

> [email protected] postinstall /home/kbuilder/.cache/synthtool/nodejs-cloudbuild/node_modules/protobufjs
> node scripts/postinstall


> @google-cloud/[email protected] prepare /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> npm run compile-protos && npm run compile


> @google-cloud/[email protected] compile-protos /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> compileProtos src

installing semver@^7.1.2
installing tmp@^0.2.0
installing uglify-js@^3.7.7
installing escodegen@^2.0.0
installing estraverse@^5.1.0

> @google-cloud/[email protected] precompile /home/kbuilder/.cache/synthtool/nodejs-cloudbuild
> gts clean

/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/node_modules/meow/index.js:61
		throw new Error(`Flag keys may not contain '-': ${invalidFlags.join(', ')}`);
		^

Error: Flag keys may not contain '-': dry-run
    at validateOptions (/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/node_modules/meow/index.js:61:9)
    at meow (/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/node_modules/meow/index.js:136:2)
    at Object.<anonymous> (/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/node_modules/gts/build/src/cli.js:30:13)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @google-cloud/[email protected] precompile: `gts clean`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @google-cloud/[email protected] precompile script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kbuilder/.npm/_logs/2021-01-07T09_12_38_630Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @google-cloud/[email protected] prepare: `npm run compile-protos && npm run compile`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @google-cloud/[email protected] prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kbuilder/.npm/_logs/2021-01-07T09_12_38_690Z-debug.log
2021-01-07 01:12:38,715 synthtool [ERROR] > Failed executing npm install:

None
ERROR:synthtool:Failed executing npm install:

None
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>
    main()
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main
    spec.loader.exec_module(synth_module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/synth.py", line 39, in <module>
    node.postprocess_gapic_library()
  File "/tmpfs/src/github/synthtool/synthtool/languages/node.py", line 193, in postprocess_gapic_library
    install(hide_output=hide_output)
  File "/tmpfs/src/github/synthtool/synthtool/languages/node.py", line 167, in install
    shell.run(["npm", "install"], hide_output=hide_output)
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 39, in run
    raise exc
  File "/tmpfs/src/github/synthtool/synthtool/shell.py", line 33, in run
    encoding="utf-8",
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['npm', 'install']' returned non-zero exit status 1.
2021-01-07 01:12:38,763 autosynth [ERROR] > Synthesis failed
2021-01-07 01:12:38,763 autosynth [DEBUG] > Running: git reset --hard HEAD
HEAD is now at 4af2a71 docs: add instructions for authenticating for system tests (#191)
2021-01-07 01:12:38,794 autosynth [DEBUG] > Running: git checkout autosynth
Switched to branch 'autosynth'
2021-01-07 01:12:38,815 autosynth [DEBUG] > Running: git clean -fdx
Removing __pycache__/
Removing node_modules/
Traceback (most recent call last):
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 354, in <module>
    main()
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 189, in main
    return _inner_main(temp_dir)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 334, in _inner_main
    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)
  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 65, in synthesize_loop
    has_changes = toolbox.synthesize_version_in_new_branch(synthesizer, youngest)
  File "/tmpfs/src/github/synthtool/autosynth/synth_toolbox.py", line 259, in synthesize_version_in_new_branch
    synthesizer.synthesize(synth_log_path, self.environ)
  File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 120, in synthesize
    synth_proc.check_returncode()  # Raise an exception.
  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode
    self.stderr)
subprocess.CalledProcessError: Command '['/tmpfs/src/github/synthtool/env/bin/python3', '-m', 'synthtool', '--metadata', 'synth.metadata', 'synth.py', '--']' returned non-zero exit status 1.

Google internal developers can see the full log here.

Cloud Builder Node.js createBuild API example

I am trying to replicate the create build python example using Node.js. The example enables a cloud function to call Cloud Build without setting a trigger based on a gcloud command.

My assumption was that the runtime libraries would have parity between Python/Node? However when I try the example in Node.js I am unable to initiate a build. Example code used below:

// Imports the Google Cloud client library
const {CloudBuildClient} = require('@google-cloud/cloudbuild');

// Creates a client
const cb = new CloudBuildClient();

// Add a project ID from the environment - std PROJECT_ID definition based on homepage
const PROJECT_ID = process.env.PROJECT_ID || 'PRJ_ERROR';

// Process the function
async function step_one_function() {
  // Starts a build against the branch provided.
  console.log(`Project ID: ${PROJECT_ID}`);
  const build = {
            "steps": [
            {
              "name": "bash",
              "args": ["echo", "Hello Cloud Build"],
            }
          ],
  }
  // Call the createBuild function
  const [resp] = await cb.createBuild(PROJECT_ID, build );

  console.log(`Response: ${resp}`);
}

package.json

  "dependencies": {
    "@google-cloud/cloudbuild": "^2.0.3"
  },

I believe I need to supply the build parameter as a google.devtools.cloudbuild.v1.ICreateBuildRequest however, I am not clear how to create the build object based on the documentation. I tried to keep the example simple to illustrate the issue.

Would someone be able to clarify how this variable is defined and how to utilise the createBuild function to get a similar outcome to the Python version of the library?

Many thanks

Rich

Synthesis failed for nodejs-cloudbuild

Hello! Autosynth couldn't regenerate nodejs-cloudbuild. ๐Ÿ’”

Here's the output from running synth.py:

b'encies.\nDEBUG:synthtool:Ensuring dependencies.\n2020-06-05 04:23:02,540 synthtool [DEBUG] > Cloning googleapis.\nDEBUG:synthtool:Cloning googleapis.\n2020-06-05 04:23:02,541 synthtool [DEBUG] > Using precloned repo /home/kbuilder/.cache/synthtool/googleapis\nDEBUG:synthtool:Using precloned repo /home/kbuilder/.cache/synthtool/googleapis\n2020-06-05 04:23:02,544 synthtool [DEBUG] > Pulling Docker image: gapic-generator-typescript:latest\nDEBUG:synthtool:Pulling Docker image: gapic-generator-typescript:latest\nlatest: Pulling from gapic-images/gapic-generator-typescript\nDigest: sha256:c9bc12024eddcfb94501627ff5b3ea302370995e9a2c9cde6b3317375d7e7b66\nStatus: Image is up to date for gcr.io/gapic-images/gapic-generator-typescript:latest\n2020-06-05 04:23:03,434 synthtool [DEBUG] > Generating code for: google/devtools/cloudbuild/v1.\nDEBUG:synthtool:Generating code for: google/devtools/cloudbuild/v1.\n2020-06-05 04:23:04,256 synthtool [DEBUG] > Wrote metadata to synth.metadata.\nDEBUG:synthtool:Wrote metadata to synth.metadata.\nTraceback (most recent call last):\n  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main\n    "__main__", mod_spec)\n  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code\n    exec(code, run_globals)\n  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>\n    main()\n  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__\n    return self.main(*args, **kwargs)\n  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main\n    rv = self.invoke(ctx)\n  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke\n    return ctx.invoke(self.callback, **ctx.params)\n  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke\n    return callback(*args, **kwargs)\n  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main\n    spec.loader.exec_module(synth_module)  # type: ignore\n  File "<frozen importlib._bootstrap_external>", line 678, in exec_module\n  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed\n  File "/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/synth.py", line 37, in <module>\n    version=version)\n  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_microgenerator.py", line 66, in typescript_library\n    return self._generate_code(service, version, "typescript", **kwargs)\n  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_microgenerator.py", line 195, in _generate_code\n    f"Code generation seemed to succeed, but {output_dir} is empty."\nRuntimeError: Code generation seemed to succeed, but /tmpfs/tmp/tmp_qv8vkoy is empty.\n2020-06-05 04:23:04,299 autosynth [ERROR] > Synthesis failed\n2020-06-05 04:23:04,299 autosynth [DEBUG] > Running: git reset --hard HEAD\nHEAD is now at 2bed454 build: do not fail builds on codecov errors (#528) (#116)\n2020-06-05 04:23:04,304 autosynth [DEBUG] > Running: git checkout autosynth-googleapis\nSwitched to branch \'autosynth-googleapis\'\n2020-06-05 04:23:04,309 autosynth [ERROR] > Command \'[\'/tmpfs/src/github/synthtool/env/bin/python3\', \'-m\', \'synthtool\', \'--metadata\', \'synth.metadata\', \'synth.py\', \'--\']\' returned non-zero exit status 1.\n2020-06-05 04:23:04,448 autosynth [DEBUG] > Running: git checkout 2bed454946812b16a995422f773b2406a69d1d2d\nNote: checking out \'2bed454946812b16a995422f773b2406a69d1d2d\'.\n\nYou are in \'detached HEAD\' state. You can look around, make experimental\nchanges and commit them, and you can discard any commits you make in this\nstate without impacting any branches by performing another checkout.\n\nIf you want to create a new branch to retain commits you create, you may\ndo so (now or later) by using -b with the checkout command again. Example:\n\n  git checkout -b <new-branch-name>\n\nHEAD is now at 2bed454 build: do not fail builds on codecov errors (#528) (#116)\n2020-06-05 04:23:04,454 autosynth [DEBUG] > Running: git checkout cd804bab06e46dd1a4f16c32155fd3cddb931b52\nHEAD is now at cd804bab docs: cleaned docs for the Agents service and resource.\n2020-06-05 04:23:04,467 autosynth [DEBUG] > Running: git checkout d53a5b45c46920932dbe7d0a95e10d8b58933dae\nPrevious HEAD position was be74d3e build: do not fail builds on codecov errors (#528)\nHEAD is now at d53a5b4 docs: improve README (#600)\n2020-06-05 04:23:04,484 autosynth [DEBUG] > Running: git branch -f autosynth-128\n2020-06-05 04:23:04,488 autosynth [DEBUG] > Running: git checkout autosynth-128\nSwitched to branch \'autosynth-128\'\n2020-06-05 04:23:04,493 autosynth [INFO] > Running synthtool\n2020-06-05 04:23:04,493 autosynth [INFO] > [\'/tmpfs/src/github/synthtool/env/bin/python3\', \'-m\', \'synthtool\', \'--metadata\', \'synth.metadata\', \'synth.py\', \'--\']\n2020-06-05 04:23:04,495 autosynth [DEBUG] > Running: /tmpfs/src/github/synthtool/env/bin/python3 -m synthtool --metadata synth.metadata synth.py --\n2020-06-05 04:23:04,702 synthtool [DEBUG] > Executing /home/kbuilder/.cache/synthtool/nodejs-cloudbuild/synth.py.\nOn branch autosynth-128\nnothing to commit, working tree clean\n2020-06-05 04:23:04,835 synthtool [DEBUG] > Ensuring dependencies.\nDEBUG:synthtool:Ensuring dependencies.\n2020-06-05 04:23:04,841 synthtool [DEBUG] > Cloning googleapis.\nDEBUG:synthtool:Cloning googleapis.\n2020-06-05 04:23:04,842 synthtool [DEBUG] > Using precloned repo /home/kbuilder/.cache/synthtool/googleapis\nDEBUG:synthtool:Using precloned repo /home/kbuilder/.cache/synthtool/googleapis\n2020-06-05 04:23:04,845 synthtool [DEBUG] > Pulling Docker image: gapic-generator-typescript:latest\nDEBUG:synthtool:Pulling Docker image: gapic-generator-typescript:latest\nlatest: Pulling from gapic-images/gapic-generator-typescript\nDigest: sha256:c9bc12024eddcfb94501627ff5b3ea302370995e9a2c9cde6b3317375d7e7b66\nStatus: Image is up to date for gcr.io/gapic-images/gapic-generator-typescript:latest\n2020-06-05 04:23:05,728 synthtool [DEBUG] > Generating code for: google/devtools/cloudbuild/v1.\nDEBUG:synthtool:Generating code for: google/devtools/cloudbuild/v1.\n2020-06-05 04:23:06,539 synthtool [DEBUG] > Wrote metadata to synth.metadata.\nDEBUG:synthtool:Wrote metadata to synth.metadata.\nTraceback (most recent call last):\n  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main\n    "__main__", mod_spec)\n  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code\n    exec(code, run_globals)\n  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 102, in <module>\n    main()\n  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 829, in __call__\n    return self.main(*args, **kwargs)\n  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 782, in main\n    rv = self.invoke(ctx)\n  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke\n    return ctx.invoke(self.callback, **ctx.params)\n  File "/tmpfs/src/github/synthtool/env/lib/python3.6/site-packages/click/core.py", line 610, in invoke\n    return callback(*args, **kwargs)\n  File "/tmpfs/src/github/synthtool/synthtool/__main__.py", line 94, in main\n    spec.loader.exec_module(synth_module)  # type: ignore\n  File "<frozen importlib._bootstrap_external>", line 678, in exec_module\n  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed\n  File "/home/kbuilder/.cache/synthtool/nodejs-cloudbuild/synth.py", line 37, in <module>\n    version=version)\n  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_microgenerator.py", line 66, in typescript_library\n    return self._generate_code(service, version, "typescript", **kwargs)\n  File "/tmpfs/src/github/synthtool/synthtool/gcp/gapic_microgenerator.py", line 195, in _generate_code\n    f"Code generation seemed to succeed, but {output_dir} is empty."\nRuntimeError: Code generation seemed to succeed, but /tmpfs/tmp/tmpbmslzwm9 is empty.\n2020-06-05 04:23:06,580 autosynth [ERROR] > Synthesis failed\n2020-06-05 04:23:06,580 autosynth [DEBUG] > Running: git reset --hard HEAD\nHEAD is now at 2bed454 build: do not fail builds on codecov errors (#528) (#116)\n2020-06-05 04:23:06,585 autosynth [DEBUG] > Running: git checkout autosynth\nSwitched to branch \'autosynth\'\n2020-06-05 04:23:06,590 autosynth [DEBUG] > Running: git clean -fdx\nRemoving __pycache__/\nTraceback (most recent call last):\n  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 193, in _run_module_as_main\n    "__main__", mod_spec)\n  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 85, in _run_code\n    exec(code, run_globals)\n  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 615, in <module>\n    main()\n  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 476, in main\n    return _inner_main(temp_dir)\n  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 595, in _inner_main\n    commit_count = synthesize_loop(x, multiple_prs, change_pusher, synthesizer)\n  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 371, in synthesize_loop\n    synthesize_inner_loop(toolbox, synthesizer)\n  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 381, in synthesize_inner_loop\n    synthesizer, len(toolbox.versions) - 1\n  File "/tmpfs/src/github/synthtool/autosynth/synth.py", line 266, in synthesize_version_in_new_branch\n    synthesizer.synthesize(synth_log_path, self.environ)\n  File "/tmpfs/src/github/synthtool/autosynth/synthesizer.py", line 119, in synthesize\n    synth_proc.check_returncode()  # Raise an exception.\n  File "/home/kbuilder/.pyenv/versions/3.6.9/lib/python3.6/subprocess.py", line 389, in check_returncode\n    self.stderr)\nsubprocess.CalledProcessError: Command \'[\'/tmpfs/src/github/synthtool/env/bin/python3\', \'-m\', \'synthtool\', \'--metadata\', \'synth.metadata\', \'synth.py\', \'--\']\' returned non-zero exit status 1.\n'

Google internal developers can see the full log here.

502:Bad Gateway error when running runBuildTrigger

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS: Google Cloud Functions
  • Node.js version: 10
  • npm version: 6.14.5
  • @google-cloud/cloudbuild version: 1.5.0

Steps to reproduce

  1. const cb = new CloudBuildClient();
  2. cb.runBuildTrigger({
    projectId,
    triggerId,
    source: {
    projectId,
    dir: "./",
    branchName,
    },
    },(callback) => {
    console.log(callback);
    });

It was working fine but late Monday, June 1st, something must've changed.
We're (inconsistently but around 90% of the time) an UNAVAILABLE: 502:Bad Gateway error on the callback.

Manually triggering the Build via the Cloud Console Dashboard works fine, but I'm not sure how to debug this app to get to the root of the problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.