From fabe44129d87cba435b9f02d8124779848b8eccd Mon Sep 17 00:00:00 2001 From: Ignacio Rodriguez Date: Tue, 13 Sep 2022 20:46:21 -0300 Subject: [PATCH] Add direct relationship between Cloud Build and Cloud Source Repository --- docs/jupiterone.md | 1 + src/getStepStartStates.ts | 6 + src/index.test.ts | 4 + src/steps/cloud-build/constants.ts | 20 + src/steps/cloud-build/index.ts | 2 + .../recording.har | 496 ++++++++++++++++++ ...ild-uses-source-repo-relationships.test.ts | 47 ++ ...ud-build-uses-source-repo-relationships.ts | 40 ++ 8 files changed, 616 insertions(+) create mode 100644 src/steps/cloud-build/steps/__recordings__/build-cloud-build-uses-source-repo-relationships_1963102466/recording.har create mode 100644 src/steps/cloud-build/steps/build-cloud-build-uses-source-repo-relationships.test.ts create mode 100644 src/steps/cloud-build/steps/build-cloud-build-uses-source-repo-relationships.ts diff --git a/docs/jupiterone.md b/docs/jupiterone.md index 0343ddfb..e72d6159 100644 --- a/docs/jupiterone.md +++ b/docs/jupiterone.md @@ -437,6 +437,7 @@ The following relationships are created: | `google_cloud_audit_config` | **ALLOWS** | `google_user` | | `google_cloud_bitbucket_server_config` | **HAS** | `google_cloud_bitbucket_server_repo` | | `google_cloud_build_trigger` | **TRIGGERS** | `google_cloud_build` | +| `google_cloud_build` | **USES** | `google_cloud_source_repository` | | `google_cloud_build` | **USES** | `google_storage_bucket` | | `internet` | **ALLOWS** | `google_compute_firewall` | | `google_cloud_folder` | **HAS** | `google_cloud_folder` | diff --git a/src/getStepStartStates.ts b/src/getStepStartStates.ts index 63009b4a..5ed601e5 100644 --- a/src/getStepStartStates.ts +++ b/src/getStepStartStates.ts @@ -439,6 +439,10 @@ function getDefaultStepStartStates(params: { [CloudSourceRepositoriesStepsSpec.FETCH_REPOSITORIES.id]: { disabled: false, }, + [CloudBuildStepsSpec.BUILD_CLOUD_BUILD_USES_SOURCE_REPOSITORY_RELATIONSHIPS + .id]: { + disabled: false, + }, }; logger.info( @@ -839,6 +843,8 @@ async function getStepStartStatesUsingServiceEnablements(params: { ServiceUsageName.CLOUD_SOURCE_REPOSITORIES, ServiceUsageName.CLOUD_BUILD, ), + [CloudBuildStepsSpec.BUILD_CLOUD_BUILD_USES_SOURCE_REPOSITORY_RELATIONSHIPS + .id]: createStepStartState(ServiceUsageName.CLOUD_BUILD), }; logger.info( diff --git a/src/index.test.ts b/src/index.test.ts index c28e671d..322f48b2 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -666,6 +666,10 @@ describe('#getStepStartStates success', () => { [CloudSourceRepositoriesStepsSpec.FETCH_REPOSITORIES.id]: { disabled: false, }, + [CloudBuildStepsSpec + .BUILD_CLOUD_BUILD_USES_SOURCE_REPOSITORY_RELATIONSHIPS.id]: { + disabled: false, + }, }; expect(stepStartStates).toEqual(expectedStepStartStates); diff --git a/src/steps/cloud-build/constants.ts b/src/steps/cloud-build/constants.ts index ad66353a..6be3cafb 100644 --- a/src/steps/cloud-build/constants.ts +++ b/src/steps/cloud-build/constants.ts @@ -1,4 +1,8 @@ import { RelationshipClass } from '@jupiterone/integration-sdk-core'; +import { + CloudSourceRepositoriesEntitiesSpec, + CloudSourceRepositoriesStepsSpec, +} from '../cloud-source-repositories/constants'; import { CLOUD_STORAGE_BUCKET_ENTITY_TYPE, STEP_CLOUD_STORAGE_BUCKETS, @@ -56,6 +60,12 @@ export const CloudBuildRelationshipsSpec = { sourceType: CloudBuildEntitiesSpec.BUILD._type, targetType: CLOUD_STORAGE_BUCKET_ENTITY_TYPE, }, + BUILD_USES_SOURCE_REPOSITORY: { + _type: 'google_cloud_build_uses_source_repository', + _class: RelationshipClass.USES, + sourceType: CloudBuildEntitiesSpec.BUILD._type, + targetType: CloudSourceRepositoriesEntitiesSpec.REPOSITORY._type, + }, }; export const CloudBuildStepsSpec = { @@ -110,6 +120,16 @@ export const CloudBuildStepsSpec = { relationships: [CloudBuildRelationshipsSpec.BUILD_USES_STORAGE_BUCKET], dependsOn: ['fetch-cloud-builds', STEP_CLOUD_STORAGE_BUCKETS], }, + BUILD_CLOUD_BUILD_USES_SOURCE_REPOSITORY_RELATIONSHIPS: { + id: 'build-cloud-build-uses-source-repo-relationships', + name: 'Build Cloud Build -> Source Repository Relationships', + entities: [], + relationships: [CloudBuildRelationshipsSpec.BUILD_USES_SOURCE_REPOSITORY], + dependsOn: [ + 'fetch-cloud-builds', + CloudSourceRepositoriesStepsSpec.FETCH_REPOSITORIES.id, + ], + }, }; // https://cloud.google.com/build/docs/locations diff --git a/src/steps/cloud-build/index.ts b/src/steps/cloud-build/index.ts index 8074b99b..0c522061 100644 --- a/src/steps/cloud-build/index.ts +++ b/src/steps/cloud-build/index.ts @@ -1,6 +1,7 @@ import { IntegrationStep } from '@jupiterone/integration-sdk-core'; import { IntegrationConfig } from '../../types'; import { buildCloudBuildTriggerTriggersBuildRelationshipsStep } from './steps/build-cloud-build-trigger-triggers-build-relationships'; +import { buildCloudBuildUsesSourceRepositoryRelationshipsStep } from './steps/build-cloud-build-uses-source-repo-relationships'; import { buildCloudBuildUsesStorageBucketRelationshipsStep } from './steps/build-cloud-build-uses-storage-bucket-relationships'; import { fetchCloudBuildBitbucketServerConfigStep } from './steps/fetch-cloud-build-bb-configs'; import { fetchCloudBuildBitbucketRepositoriesStep } from './steps/fetch-cloud-build-bb-repos'; @@ -19,4 +20,5 @@ export const cloudBuildSteps: IntegrationStep[] = [ buildCloudBuildTriggerTriggersBuildRelationshipsStep, buildCloudBuildUsesStorageBucketRelationshipsStep, + buildCloudBuildUsesSourceRepositoryRelationshipsStep, ]; diff --git a/src/steps/cloud-build/steps/__recordings__/build-cloud-build-uses-source-repo-relationships_1963102466/recording.har b/src/steps/cloud-build/steps/__recordings__/build-cloud-build-uses-source-repo-relationships_1963102466/recording.har new file mode 100644 index 00000000..52ad0c15 --- /dev/null +++ b/src/steps/cloud-build/steps/__recordings__/build-cloud-build-uses-source-repo-relationships_1963102466/recording.har @@ -0,0 +1,496 @@ +{ + "log": { + "_recordingName": "build-cloud-build-uses-source-repo-relationships", + "creator": { + "comment": "persister:JupiterOneIntegationFSPersister", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "acea721c8193b51ced888cae721cc423", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 709, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/x-www-form-urlencoded" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "709" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip,deflate" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "www.googleapis.com" + } + ], + "headersSize": 300, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/x-www-form-urlencoded", + "params": [], + "text": "[REDACTED]" + }, + "queryString": [], + "url": "https://www.googleapis.com/oauth2/v4/token" + }, + "response": { + "bodySize": 465, + "content": { + "encoding": "utf-8", + "mimeType": "application/json; charset=UTF-8", + "size": 465, + "text": "{\"access_token\":\"[REDACTED]\",\"expires_in\":9999,\"token_type\":\"Bearer\"}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json; charset=UTF-8" + }, + { + "name": "vary", + "value": "Origin, X-Origin, Referer" + }, + { + "name": "date", + "value": "Tue, 13 Sep 2022 23:45:10 GMT" + }, + { + "name": "server", + "value": "scaffolding on HTTPServer2" + }, + { + "name": "cache-control", + "value": "private" + }, + { + "name": "x-xss-protection", + "value": "0" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"" + }, + { + "name": "connection", + "value": "close" + } + ], + "headersSize": 506, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2022-09-13T23:45:10.593Z", + "time": 135, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 135 + } + }, + { + "_id": "df1b957f480d7d7232172cd2befb4709", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "x-goog-api-client", + "value": "gdcl/5.0.2 gl-node/14.20.0 auth/7.1.1" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "google-api-nodejs-client/5.0.2 (gzip)" + }, + { + "_fromType": "array", + "name": "authorization", + "value": "[REDACTED]" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "cloudbuild.googleapis.com" + } + ], + "headersSize": 1352, + "httpVersion": "HTTP/1.1", + "method": "GET", + "queryString": [], + "url": "https://cloudbuild.googleapis.com/v1/projects/j1-gc-integration-dev-v3/builds" + }, + "response": { + "bodySize": 5096, + "content": { + "encoding": "utf-8", + "mimeType": "application/json; charset=UTF-8", + "size": 5096, + "text": "{\"builds\":[{\"id\":\"4ff707b3-6063-412a-a3c0-894d017ca2e2\",\"status\":\"SUCCESS\",\"source\":{\"repoSource\":{\"projectId\":\"j1-gc-integration-dev-v3\",\"repoName\":\"nacho\",\"commitSha\":\"1f0e23176ea1b0d8a87284c7439db51c0a8a85a4\"}},\"createTime\":\"2022-09-13T23:42:10.184559831Z\",\"startTime\":\"2022-09-13T23:42:10.812103523Z\",\"finishTime\":\"2022-09-13T23:42:21.537432Z\",\"results\":{\"buildStepImages\":[\"sha256:20fa2d7bb4de7723f542be5923b06c4d704370f0390e4ae9e1c833c8785644c1\"],\"buildStepOutputs\":[\"\"]},\"steps\":[{\"name\":\"ubuntu\",\"args\":[\"bash\",\"-c\",\"echo hello world\"],\"timing\":{\"startTime\":\"2022-09-13T23:42:18.597796828Z\",\"endTime\":\"2022-09-13T23:42:20.761341354Z\"},\"status\":\"SUCCESS\",\"pullTiming\":{\"startTime\":\"2022-09-13T23:42:18.597796828Z\",\"endTime\":\"2022-09-13T23:42:19.963862134Z\"}}],\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"sourceProvenance\":{\"resolvedRepoSource\":{\"projectId\":\"j1-gc-integration-dev-v3\",\"repoName\":\"nacho\",\"commitSha\":\"1f0e23176ea1b0d8a87284c7439db51c0a8a85a4\"}},\"buildTriggerId\":\"5aa1ece1-ec55-48b3-828b-51ec1aa74bbd\",\"options\":{\"substitutionOption\":\"ALLOW_LOOSE\",\"logging\":\"LEGACY\",\"dynamicSubstitutions\":true,\"pool\":{}},\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/4ff707b3-6063-412a-a3c0-894d017ca2e2?project=167984947943\",\"substitutions\":{\"TRIGGER_BUILD_CONFIG_PATH\":\"cloudbuild.yaml\",\"REPO_NAME\":\"nacho\",\"REVISION_ID\":\"1f0e23176ea1b0d8a87284c7439db51c0a8a85a4\",\"COMMIT_SHA\":\"1f0e23176ea1b0d8a87284c7439db51c0a8a85a4\",\"SHORT_SHA\":\"1f0e231\",\"BRANCH_NAME\":\"main\",\"REF_NAME\":\"main\",\"TRIGGER_NAME\":\"cloudsource-trigger\"},\"tags\":[\"trigger-5aa1ece1-ec55-48b3-828b-51ec1aa74bbd\"],\"timing\":{\"FETCHSOURCE\":{\"startTime\":\"2022-09-13T23:42:11.448109277Z\",\"endTime\":\"2022-09-13T23:42:17.886247774Z\"},\"BUILD\":{\"startTime\":\"2022-09-13T23:42:17.886313637Z\",\"endTime\":\"2022-09-13T23:42:20.761419176Z\"}},\"queueTtl\":\"3600s\",\"name\":\"projects/167984947943/locations/global/builds/4ff707b3-6063-412a-a3c0-894d017ca2e2\"},{\"id\":\"175e3790-16cb-41db-9868-53130a6cd730\",\"status\":\"SUCCESS\",\"source\":{\"storageSource\":{\"bucket\":\"j1-gc-integration-dev-v3_cloudbuild\",\"object\":\"source/1663112478.409473-04d23fd8c665482aaf1ef80179a84ccf.tgz\",\"generation\":\"1663112479817046\"}},\"createTime\":\"2022-09-13T23:41:20.205811477Z\",\"startTime\":\"2022-09-13T23:41:21.862330907Z\",\"finishTime\":\"2022-09-13T23:41:29.103706Z\",\"results\":{\"buildStepImages\":[\"sha256:20fa2d7bb4de7723f542be5923b06c4d704370f0390e4ae9e1c833c8785644c1\"],\"buildStepOutputs\":[\"\"]},\"steps\":[{\"name\":\"ubuntu\",\"args\":[\"bash\",\"-c\",\"echo hello world\"],\"timing\":{\"startTime\":\"2022-09-13T23:41:27.144377521Z\",\"endTime\":\"2022-09-13T23:41:28.596114440Z\"},\"status\":\"SUCCESS\",\"pullTiming\":{\"startTime\":\"2022-09-13T23:41:27.144377521Z\",\"endTime\":\"2022-09-13T23:41:27.989549040Z\"}}],\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"sourceProvenance\":{\"resolvedStorageSource\":{\"bucket\":\"j1-gc-integration-dev-v3_cloudbuild\",\"object\":\"source/1663112478.409473-04d23fd8c665482aaf1ef80179a84ccf.tgz\",\"generation\":\"1663112479817046\"},\"fileHashes\":{\"gs://j1-gc-integration-dev-v3_cloudbuild/source/1663112478.409473-04d23fd8c665482aaf1ef80179a84ccf.tgz#1663112479817046\":{\"fileHash\":[{\"type\":\"MD5\",\"value\":\"N0XWkij3to+JVSeVQxSeZA==\"}]}}},\"options\":{\"logging\":\"LEGACY\",\"pool\":{}},\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/175e3790-16cb-41db-9868-53130a6cd730?project=167984947943\",\"timing\":{\"FETCHSOURCE\":{\"startTime\":\"2022-09-13T23:41:22.349578043Z\",\"endTime\":\"2022-09-13T23:41:26.648486891Z\"},\"BUILD\":{\"startTime\":\"2022-09-13T23:41:26.648552996Z\",\"endTime\":\"2022-09-13T23:41:28.596170744Z\"}},\"queueTtl\":\"3600s\",\"name\":\"projects/167984947943/locations/global/builds/175e3790-16cb-41db-9868-53130a6cd730\"},{\"id\":\"7daffe81-bf57-419b-8972-6f6e9749072e\",\"status\":\"FAILURE\",\"createTime\":\"2022-09-13T23:27:25.970043355Z\",\"startTime\":\"2022-09-13T23:27:25.970043355Z\",\"finishTime\":\"2022-09-13T23:27:25.970043355Z\",\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"buildTriggerId\":\"5aa1ece1-ec55-48b3-828b-51ec1aa74bbd\",\"options\":{\"logging\":\"LEGACY\"},\"statusDetail\":\"cloud.j1-gc-integration-dev-v3/nacho:cloudbuild.yaml: \",\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/7daffe81-bf57-419b-8972-6f6e9749072e?project=167984947943\",\"tags\":[\"trigger-5aa1ece1-ec55-48b3-828b-51ec1aa74bbd\"],\"queueTtl\":\"3600s\"},{\"id\":\"3d408da8-beb8-4292-be46-327ccb6e7df8\",\"status\":\"FAILURE\",\"createTime\":\"2022-09-06T10:08:42.371350225Z\",\"startTime\":\"2022-09-06T10:08:42.371350225Z\",\"finishTime\":\"2022-09-06T10:08:42.371350225Z\",\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"buildTriggerId\":\"56a965d9-25ba-4514-b8a8-f38eec256cf0\",\"options\":{\"logging\":\"LEGACY\"},\"statusDetail\":\"request failed with status=404 status_message=\\\"404 \\\" body=\\\"{\\\\\\\"errors\\\\\\\":[{\\\\\\\"context\\\\\\\":null,\\\\\\\"message\\\\\\\":\\\\\\\"The path \\\\\\\\\\\\\\\"cloudbuild.yaml\\\\\\\\\\\\\\\" does not exist at revision \\\\\\\\\\\\\\\"058328ca9cafcbe335393c27c442eda6809a04e7\\\\\\\\\\\\\\\"\\\\\\\",\\\\\\\"exceptionName\\\\\\\":\\\\\\\"com.atlassian.bitbucket.content.NoSuchPathException\\\\\\\"}]}\\\"\",\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/3d408da8-beb8-4292-be46-327ccb6e7df8?project=167984947943\",\"tags\":[\"trigger-56a965d9-25ba-4514-b8a8-f38eec256cf0\"],\"queueTtl\":\"3600s\"},{\"id\":\"cc0a06e2-6fb4-4a3f-a7b2-989e4aeb73d9\",\"status\":\"FAILURE\",\"createTime\":\"2022-09-06T10:08:41.691917248Z\",\"startTime\":\"2022-09-06T10:08:41.691917248Z\",\"finishTime\":\"2022-09-06T10:08:41.691917248Z\",\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"buildTriggerId\":\"56a965d9-25ba-4514-b8a8-f38eec256cf0\",\"options\":{\"logging\":\"LEGACY\"},\"statusDetail\":\"request failed with status=404 status_message=\\\"404 \\\" body=\\\"{\\\\\\\"errors\\\\\\\":[{\\\\\\\"context\\\\\\\":null,\\\\\\\"message\\\\\\\":\\\\\\\"The path \\\\\\\\\\\\\\\"cloudbuild.yaml\\\\\\\\\\\\\\\" does not exist at revision \\\\\\\\\\\\\\\"900468f8ec2055fd7b30ae5fc2cb9fa2057b83ef\\\\\\\\\\\\\\\"\\\\\\\",\\\\\\\"exceptionName\\\\\\\":\\\\\\\"com.atlassian.bitbucket.content.NoSuchPathException\\\\\\\"}]}\\\"\",\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/cc0a06e2-6fb4-4a3f-a7b2-989e4aeb73d9?project=167984947943\",\"tags\":[\"trigger-56a965d9-25ba-4514-b8a8-f38eec256cf0\"],\"queueTtl\":\"3600s\"},{\"id\":\"ba2298ce-c745-42a9-969f-78e856df7236\",\"status\":\"FAILURE\",\"createTime\":\"2022-09-06T10:08:41.692937396Z\",\"startTime\":\"2022-09-06T10:08:41.692937396Z\",\"finishTime\":\"2022-09-06T10:08:41.692937396Z\",\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"buildTriggerId\":\"56a965d9-25ba-4514-b8a8-f38eec256cf0\",\"options\":{\"logging\":\"LEGACY\"},\"statusDetail\":\"request failed with status=404 status_message=\\\"404 \\\" body=\\\"{\\\\\\\"errors\\\\\\\":[{\\\\\\\"context\\\\\\\":null,\\\\\\\"message\\\\\\\":\\\\\\\"The path \\\\\\\\\\\\\\\"cloudbuild.yaml\\\\\\\\\\\\\\\" does not exist at revision \\\\\\\\\\\\\\\"fdea5047622b4f0fbd2e033e7ae155b33898af09\\\\\\\\\\\\\\\"\\\\\\\",\\\\\\\"exceptionName\\\\\\\":\\\\\\\"com.atlassian.bitbucket.content.NoSuchPathException\\\\\\\"}]}\\\"\",\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/ba2298ce-c745-42a9-969f-78e856df7236?project=167984947943\",\"tags\":[\"trigger-56a965d9-25ba-4514-b8a8-f38eec256cf0\"],\"queueTtl\":\"3600s\"},{\"id\":\"a0564259-83a7-482f-b85a-af25d995e0db\",\"status\":\"FAILURE\",\"createTime\":\"2022-09-06T10:08:40.820293031Z\",\"startTime\":\"2022-09-06T10:08:40.820293031Z\",\"finishTime\":\"2022-09-06T10:08:40.820293031Z\",\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"buildTriggerId\":\"56a965d9-25ba-4514-b8a8-f38eec256cf0\",\"options\":{\"logging\":\"LEGACY\"},\"statusDetail\":\"request failed with status=404 status_message=\\\"404 \\\" body=\\\"{\\\\\\\"errors\\\\\\\":[{\\\\\\\"context\\\\\\\":null,\\\\\\\"message\\\\\\\":\\\\\\\"The path \\\\\\\\\\\\\\\"cloudbuild.yaml\\\\\\\\\\\\\\\" does not exist at revision \\\\\\\\\\\\\\\"857bef17c2f34947383fb6db6c392679317d2255\\\\\\\\\\\\\\\"\\\\\\\",\\\\\\\"exceptionName\\\\\\\":\\\\\\\"com.atlassian.bitbucket.content.NoSuchPathException\\\\\\\"}]}\\\"\",\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/a0564259-83a7-482f-b85a-af25d995e0db?project=167984947943\",\"tags\":[\"trigger-56a965d9-25ba-4514-b8a8-f38eec256cf0\"],\"queueTtl\":\"3600s\"},{\"id\":\"64fb26e1-abc2-49f0-af5a-f5ba453bbb53\",\"status\":\"FAILURE\",\"createTime\":\"2022-09-06T10:08:40.540598437Z\",\"startTime\":\"2022-09-06T10:08:40.540598437Z\",\"finishTime\":\"2022-09-06T10:08:40.540598437Z\",\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"buildTriggerId\":\"56a965d9-25ba-4514-b8a8-f38eec256cf0\",\"options\":{\"logging\":\"LEGACY\"},\"statusDetail\":\"request failed with status=404 status_message=\\\"404 \\\" body=\\\"{\\\\\\\"errors\\\\\\\":[{\\\\\\\"context\\\\\\\":null,\\\\\\\"message\\\\\\\":\\\\\\\"The path \\\\\\\\\\\\\\\"cloudbuild.yaml\\\\\\\\\\\\\\\" does not exist at revision \\\\\\\\\\\\\\\"bbca04b5ea664c1f9082af859f31e2f641b1e733\\\\\\\\\\\\\\\"\\\\\\\",\\\\\\\"exceptionName\\\\\\\":\\\\\\\"com.atlassian.bitbucket.content.NoSuchPathException\\\\\\\"}]}\\\"\",\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/64fb26e1-abc2-49f0-af5a-f5ba453bbb53?project=167984947943\",\"tags\":[\"trigger-56a965d9-25ba-4514-b8a8-f38eec256cf0\"],\"queueTtl\":\"3600s\"},{\"id\":\"00857679-5db9-4107-aaaf-196261b74438\",\"status\":\"FAILURE\",\"createTime\":\"2022-09-06T10:08:13.710738635Z\",\"startTime\":\"2022-09-06T10:08:13.710738635Z\",\"finishTime\":\"2022-09-06T10:08:13.710738635Z\",\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"buildTriggerId\":\"56a965d9-25ba-4514-b8a8-f38eec256cf0\",\"options\":{\"logging\":\"LEGACY\"},\"statusDetail\":\"request failed with status=404 status_message=\\\"404 \\\" body=\\\"{\\\\\\\"errors\\\\\\\":[{\\\\\\\"context\\\\\\\":null,\\\\\\\"message\\\\\\\":\\\\\\\"The path \\\\\\\\\\\\\\\"cloudbuild.yaml\\\\\\\\\\\\\\\" does not exist at revision \\\\\\\\\\\\\\\"06a4031a77f341da8903c46c9bb29ee633eabc65\\\\\\\\\\\\\\\"\\\\\\\",\\\\\\\"exceptionName\\\\\\\":\\\\\\\"com.atlassian.bitbucket.content.NoSuchPathException\\\\\\\"}]}\\\"\",\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/00857679-5db9-4107-aaaf-196261b74438?project=167984947943\",\"tags\":[\"trigger-56a965d9-25ba-4514-b8a8-f38eec256cf0\"],\"queueTtl\":\"3600s\"},{\"id\":\"21e049ff-cb95-42ab-992d-8cd417e3c2e7\",\"status\":\"FAILURE\",\"createTime\":\"2022-09-06T09:33:03.940887858Z\",\"startTime\":\"2022-09-06T09:33:03.940887858Z\",\"finishTime\":\"2022-09-06T09:33:03.940887858Z\",\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"buildTriggerId\":\"89e96b49-3cef-4fd4-ae19-fc261e2ca076\",\"options\":{\"logging\":\"LEGACY\"},\"statusDetail\":\"We could not find a valid build file. Please ensure that your repo contains a cloudbuild or a Dockerfile. See https://cloud.google.com/cloud-build/docs/quickstart-build\",\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/21e049ff-cb95-42ab-992d-8cd417e3c2e7?project=167984947943\",\"tags\":[\"trigger-89e96b49-3cef-4fd4-ae19-fc261e2ca076\"],\"queueTtl\":\"3600s\"},{\"id\":\"4523fc78-3518-4304-8141-aa1072877719\",\"status\":\"FAILURE\",\"createTime\":\"2022-09-06T09:32:55.256308053Z\",\"startTime\":\"2022-09-06T09:32:55.256308053Z\",\"finishTime\":\"2022-09-06T09:32:55.256308053Z\",\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"buildTriggerId\":\"56a965d9-25ba-4514-b8a8-f38eec256cf0\",\"options\":{\"logging\":\"LEGACY\"},\"statusDetail\":\"request failed with status=404 status_message=\\\"404 \\\" body=\\\"{\\\\\\\"errors\\\\\\\":[{\\\\\\\"context\\\\\\\":null,\\\\\\\"message\\\\\\\":\\\\\\\"The path \\\\\\\\\\\\\\\"cloudbuild.yaml\\\\\\\\\\\\\\\" does not exist at revision \\\\\\\\\\\\\\\"10f707944276e9e4fa98af2aba431cd4aac7b85d\\\\\\\\\\\\\\\"\\\\\\\",\\\\\\\"exceptionName\\\\\\\":\\\\\\\"com.atlassian.bitbucket.content.NoSuchPathException\\\\\\\"}]}\\\"\",\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/4523fc78-3518-4304-8141-aa1072877719?project=167984947943\",\"tags\":[\"trigger-56a965d9-25ba-4514-b8a8-f38eec256cf0\"],\"queueTtl\":\"3600s\"},{\"id\":\"dce019aa-73ea-4211-b324-eb5b5fb35901\",\"status\":\"FAILURE\",\"createTime\":\"2022-09-06T09:32:28.900792444Z\",\"startTime\":\"2022-09-06T09:32:28.900792444Z\",\"finishTime\":\"2022-09-06T09:32:28.900792444Z\",\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"buildTriggerId\":\"89e96b49-3cef-4fd4-ae19-fc261e2ca076\",\"options\":{\"logging\":\"LEGACY\"},\"statusDetail\":\"We could not find a valid build file. Please ensure that your repo contains a cloudbuild or a Dockerfile. See https://cloud.google.com/cloud-build/docs/quickstart-build\",\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/dce019aa-73ea-4211-b324-eb5b5fb35901?project=167984947943\",\"tags\":[\"trigger-89e96b49-3cef-4fd4-ae19-fc261e2ca076\"],\"queueTtl\":\"3600s\"},{\"id\":\"a124d780-f226-40e6-bde5-3c7a098cb0f0\",\"status\":\"FAILURE\",\"createTime\":\"2022-09-06T09:32:24.571086220Z\",\"startTime\":\"2022-09-06T09:32:24.571086220Z\",\"finishTime\":\"2022-09-06T09:32:24.571086220Z\",\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"buildTriggerId\":\"89e96b49-3cef-4fd4-ae19-fc261e2ca076\",\"options\":{\"logging\":\"LEGACY\"},\"statusDetail\":\"We could not find a valid build file. Please ensure that your repo contains a cloudbuild or a Dockerfile. See https://cloud.google.com/cloud-build/docs/quickstart-build\",\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/a124d780-f226-40e6-bde5-3c7a098cb0f0?project=167984947943\",\"tags\":[\"trigger-89e96b49-3cef-4fd4-ae19-fc261e2ca076\"],\"queueTtl\":\"3600s\"},{\"id\":\"5c45e5a4-0780-417b-89a9-ab3fa5b5a106\",\"status\":\"FAILURE\",\"createTime\":\"2022-09-06T06:51:36.883083481Z\",\"startTime\":\"2022-09-06T06:51:36.883083481Z\",\"finishTime\":\"2022-09-06T06:51:36.883083481Z\",\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"buildTriggerId\":\"56a965d9-25ba-4514-b8a8-f38eec256cf0\",\"options\":{\"logging\":\"LEGACY\"},\"statusDetail\":\"request failed with status=404 status_message=\\\"404 \\\" body=\\\"{\\\\\\\"errors\\\\\\\":[{\\\\\\\"context\\\\\\\":null,\\\\\\\"message\\\\\\\":\\\\\\\"The path \\\\\\\\\\\\\\\"cloudbuild.yaml\\\\\\\\\\\\\\\" does not exist at revision \\\\\\\\\\\\\\\"48e120aea6601a0401472a261551e4151d8391ac\\\\\\\\\\\\\\\"\\\\\\\",\\\\\\\"exceptionName\\\\\\\":\\\\\\\"com.atlassian.bitbucket.content.NoSuchPathException\\\\\\\"}]}\\\"\",\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/5c45e5a4-0780-417b-89a9-ab3fa5b5a106?project=167984947943\",\"tags\":[\"trigger-56a965d9-25ba-4514-b8a8-f38eec256cf0\"],\"queueTtl\":\"3600s\"},{\"id\":\"58991a72-f158-481d-ad66-771b90ce3e65\",\"status\":\"FAILURE\",\"source\":{\"storageSource\":{\"bucket\":\"j1-gc-integration-dev-v3_cloudbuild\",\"object\":\"source/1660769074.865182-d160c8803b704c60b50e68d2b3b97d73.tgz\",\"generation\":\"1660769077096260\"}},\"createTime\":\"2022-08-17T20:44:37.573002899Z\",\"startTime\":\"2022-08-17T20:44:38.421413511Z\",\"finishTime\":\"2022-08-17T20:44:46.243182675Z\",\"results\":{\"buildStepImages\":[\"sha256:0229d2fde1be1a278c6bb73fbfd98b2df63c30cb9012c882bdfa228e738afdf5\",\"\",\"\",\"\",\"\"],\"buildStepOutputs\":[\"\",\"\",\"\",\"\",\"\"]},\"steps\":[{\"name\":\"gcr.io/cloud-builders/gsutil\",\"args\":[\"-c\",\"gsutil ls -b gs:// || gsutil mb -l gs://\\n\\n(\\n gsutil cp gs:///.tar.gz /tmp/gradle-cache.tar.gz &&\\n tar -xzf /tmp/gradle-cache.tar.gz\\n) || echo 'Cache not found'\\n\"],\"dir\":\"/cachinghome\",\"waitFor\":[\"-\"],\"entrypoint\":\"bash\",\"volumes\":[{\"name\":\"caching.home\",\"path\":\"/cachinghome\"}],\"timing\":{\"startTime\":\"2022-08-17T20:44:45.021642025Z\",\"endTime\":\"2022-08-17T20:44:45.676265144Z\"},\"status\":\"FAILURE\",\"pullTiming\":{\"startTime\":\"2022-08-17T20:44:45.021642025Z\",\"endTime\":\"2022-08-17T20:44:45.023016172Z\"},\"exitCode\":1},{\"name\":\"openjdk:11\",\"args\":[\"-c\",\"set -x\\nexport CACHING_HOME=\\\"/cachinghome\\\"\\nUSER_HOME=\\\"/root\\\"\\nM2_HOME=\\\"${USER_HOME}/.m2\\\"\\nM2_CACHE=\\\"${CACHING_HOME}/maven\\\"\\nGRADLE_HOME=\\\"${USER_HOME}/.gradle\\\"\\nGRADLE_CACHE=\\\"${CACHING_HOME}/gradle\\\"\\n\\necho \\\"Generating symbolic links for caches\\\"\\nmkdir -p ${M2_CACHE}\\nmkdir -p ${GRADLE_CACHE}\\n\\n[[ -d \\\"${M2_CACHE}\\\" && ! -d \\\"${M2_HOME}\\\" ]] && ln -s \\\"${M2_CACHE}\\\" \\\"${M2_HOME}\\\"\\n[[ -d \\\"${GRADLE_CACHE}\\\" && ! -d \\\"${GRADLE_HOME}\\\" ]] && ln -s \\\"${GRADLE_CACHE}\\\" \\\"${GRADLE_HOME}\\\"\\n./gradlew check\"],\"id\":\"test\",\"entrypoint\":\"/bin/bash\",\"volumes\":[{\"name\":\"caching.home\",\"path\":\"/cachinghome\"}],\"status\":\"QUEUED\"},{\"name\":\"openjdk:11\",\"args\":[\"-c\",\"set -x\\nexport CACHING_HOME=\\\"/cachinghome\\\"\\nUSER_HOME=\\\"/root\\\"\\nM2_HOME=\\\"${USER_HOME}/.m2\\\"\\nM2_CACHE=\\\"${CACHING_HOME}/maven\\\"\\nGRADLE_HOME=\\\"${USER_HOME}/.gradle\\\"\\nGRADLE_CACHE=\\\"${CACHING_HOME}/gradle\\\"\\n\\necho \\\"Generating symbolic links for caches\\\"\\nmkdir -p ${M2_CACHE}\\nmkdir -p ${GRADLE_CACHE}\\n\\n[[ -d \\\"${M2_CACHE}\\\" && ! -d \\\"${M2_HOME}\\\" ]] && ln -s \\\"${M2_CACHE}\\\" \\\"${M2_HOME}\\\"\\n[[ -d \\\"${GRADLE_CACHE}\\\" && ! -d \\\"${GRADLE_HOME}\\\" ]] && ln -s \\\"${GRADLE_CACHE}\\\" \\\"${GRADLE_HOME}\\\"\\n./gradlew jib --image=gcr.io/j1-gc-integration-dev-v3/hello-cloud-build:\"],\"id\":\"build-image\",\"entrypoint\":\"/bin/bash\",\"volumes\":[{\"name\":\"caching.home\",\"path\":\"/cachinghome\"}],\"status\":\"QUEUED\"},{\"name\":\"gcr.io/cloud-builders/gcloud\",\"args\":[\"run\",\"deploy\",\"--image=gcr.io/j1-gc-integration-dev-v3/hello-cloud-build:\",\"--platform=managed\",\"--project=j1-gc-integration-dev-v3\",\"--region=us-central1\",\"--allow-unauthenticated\",\"--memory=256Mi\",\"--set-env-vars=SPRING_PROFILES_ACTIVE=gcp\",\"hello-cloud-build\"],\"id\":\"deploy\",\"volumes\":[{\"name\":\"caching.home\",\"path\":\"/cachinghome\"}],\"status\":\"QUEUED\"},{\"name\":\"gcr.io/cloud-builders/gsutil\",\"args\":[\"-c\",\"tar -czf /tmp/gradle-cache.tar.gz gradle/ &&\\ngsutil cp /tmp/gradle-cache.tar.gz gs:///.tar.gz\\n\"],\"dir\":\"/cachinghome\",\"waitFor\":[\"deploy\"],\"entrypoint\":\"bash\",\"volumes\":[{\"name\":\"caching.home\",\"path\":\"/cachinghome\"}],\"status\":\"QUEUED\"}],\"timeout\":\"600s\",\"projectId\":\"j1-gc-integration-dev-v3\",\"logsBucket\":\"gs://167984947943.cloudbuild-logs.googleusercontent.com\",\"sourceProvenance\":{\"resolvedStorageSource\":{\"bucket\":\"j1-gc-integration-dev-v3_cloudbuild\",\"object\":\"source/1660769074.865182-d160c8803b704c60b50e68d2b3b97d73.tgz\",\"generation\":\"1660769077096260\"},\"fileHashes\":{\"gs://j1-gc-integration-dev-v3_cloudbuild/source/1660769074.865182-d160c8803b704c60b50e68d2b3b97d73.tgz#1660769077096260\":{\"fileHash\":[{\"type\":\"MD5\",\"value\":\"eg9jmTQDqknuC0oat864jA==\"}]}}},\"options\":{\"logging\":\"LEGACY\",\"pool\":{}},\"logUrl\":\"https://console.cloud.google.com/cloud-build/builds/58991a72-f158-481d-ad66-771b90ce3e65?project=167984947943\",\"substitutions\":{\"_GCS_CACHE_BUCKET\":\"\",\"_GCS_CACHE_FILE\":\"\"},\"timing\":{\"BUILD\":{\"startTime\":\"2022-08-17T20:44:44.385497769Z\",\"endTime\":\"2022-08-17T20:44:45.676362304Z\"},\"FETCHSOURCE\":{\"startTime\":\"2022-08-17T20:44:38.927319156Z\",\"endTime\":\"2022-08-17T20:44:44.385391800Z\"}},\"queueTtl\":\"3600s\",\"name\":\"projects/167984947943/locations/global/builds/58991a72-f158-481d-ad66-771b90ce3e65\",\"failureInfo\":{\"type\":\"USER_BUILD_STEP\",\"detail\":\"Build step failure: build step 0 \\\"gcr.io/cloud-builders/gsutil\\\" failed: step exited with non-zero status: 1\"}}]}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json; charset=UTF-8" + }, + { + "name": "vary", + "value": "Origin, X-Origin, Referer" + }, + { + "name": "date", + "value": "Tue, 13 Sep 2022 23:45:11 GMT" + }, + { + "name": "server", + "value": "ESF" + }, + { + "name": "cache-control", + "value": "private" + }, + { + "name": "x-xss-protection", + "value": "0" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"" + }, + { + "name": "connection", + "value": "close" + } + ], + "headersSize": 483, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2022-09-13T23:45:10.742Z", + "time": 323, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 323 + } + }, + { + "_id": "acea721c8193b51ced888cae721cc423", + "_order": 1, + "cache": {}, + "request": { + "bodySize": 709, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/x-www-form-urlencoded" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "709" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip,deflate" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "www.googleapis.com" + } + ], + "headersSize": 300, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/x-www-form-urlencoded", + "params": [], + "text": "[REDACTED]" + }, + "queryString": [], + "url": "https://www.googleapis.com/oauth2/v4/token" + }, + "response": { + "bodySize": 499, + "content": { + "encoding": "utf-8", + "mimeType": "application/json; charset=UTF-8", + "size": 499, + "text": "{\"access_token\":\"[REDACTED]\",\"expires_in\":9999,\"token_type\":\"Bearer\"}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json; charset=UTF-8" + }, + { + "name": "vary", + "value": "Origin, X-Origin, Referer" + }, + { + "name": "date", + "value": "Tue, 13 Sep 2022 23:45:11 GMT" + }, + { + "name": "server", + "value": "scaffolding on HTTPServer2" + }, + { + "name": "cache-control", + "value": "private" + }, + { + "name": "x-xss-protection", + "value": "0" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"" + }, + { + "name": "connection", + "value": "close" + } + ], + "headersSize": 506, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2022-09-13T23:45:11.131Z", + "time": 205, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 205 + } + }, + { + "_id": "53e96d058a7bb7dbd8b3068576294ec7", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "x-goog-api-client", + "value": "gdcl/5.0.2 gl-node/14.20.0 auth/7.1.1" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "google-api-nodejs-client/5.0.2 (gzip)" + }, + { + "_fromType": "array", + "name": "authorization", + "value": "[REDACTED]" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "sourcerepo.googleapis.com" + } + ], + "headersSize": 1351, + "httpVersion": "HTTP/1.1", + "method": "GET", + "queryString": [], + "url": "https://sourcerepo.googleapis.com/v1/projects/j1-gc-integration-dev-v3/repos" + }, + "response": { + "bodySize": 199, + "content": { + "encoding": "utf-8", + "mimeType": "application/json; charset=UTF-8", + "size": 199, + "text": "{\"repos\":[{\"name\":\"projects/j1-gc-integration-dev-v3/repos/nacho\",\"url\":\"https://source.developers.google.com/p/j1-gc-integration-dev-v3/r/nacho\"}]}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json; charset=UTF-8" + }, + { + "name": "vary", + "value": "Origin, X-Origin, Referer" + }, + { + "name": "date", + "value": "Tue, 13 Sep 2022 23:45:12 GMT" + }, + { + "name": "server", + "value": "ESF" + }, + { + "name": "cache-control", + "value": "private" + }, + { + "name": "x-xss-protection", + "value": "0" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "alt-svc", + "value": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"" + }, + { + "name": "connection", + "value": "close" + } + ], + "headersSize": 483, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2022-09-13T23:45:11.350Z", + "time": 929, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 929 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/src/steps/cloud-build/steps/build-cloud-build-uses-source-repo-relationships.test.ts b/src/steps/cloud-build/steps/build-cloud-build-uses-source-repo-relationships.test.ts new file mode 100644 index 00000000..77edc83e --- /dev/null +++ b/src/steps/cloud-build/steps/build-cloud-build-uses-source-repo-relationships.test.ts @@ -0,0 +1,47 @@ +import { + executeStepWithDependencies, + Recording, + StepTestConfig, +} from '@jupiterone/integration-sdk-testing'; +import { invocationConfig } from '../../..'; +import { integrationConfig } from '../../../../test/config'; +import { + getMatchRequestsBy, + setupGoogleCloudRecording, +} from '../../../../test/recording'; +import { CloudBuildStepsSpec } from '../constants'; + +describe(`cloud-build#${CloudBuildStepsSpec.BUILD_CLOUD_BUILD_USES_SOURCE_REPOSITORY_RELATIONSHIPS.id}`, () => { + let recording: Recording; + afterEach(async () => { + if (recording) await recording.stop(); + }); + + jest.setTimeout(45000); + + test( + CloudBuildStepsSpec.BUILD_CLOUD_BUILD_USES_SOURCE_REPOSITORY_RELATIONSHIPS + .id, + async () => { + recording = setupGoogleCloudRecording({ + name: CloudBuildStepsSpec + .BUILD_CLOUD_BUILD_USES_SOURCE_REPOSITORY_RELATIONSHIPS.id, + directory: __dirname, + options: { + matchRequestsBy: getMatchRequestsBy(integrationConfig), + }, + }); + + const stepTestConfig: StepTestConfig = { + stepId: + CloudBuildStepsSpec + .BUILD_CLOUD_BUILD_USES_SOURCE_REPOSITORY_RELATIONSHIPS.id, + instanceConfig: integrationConfig, + invocationConfig: invocationConfig as any, + }; + + const result = await executeStepWithDependencies(stepTestConfig); + expect(result).toMatchStepMetadata(stepTestConfig); + }, + ); +}); diff --git a/src/steps/cloud-build/steps/build-cloud-build-uses-source-repo-relationships.ts b/src/steps/cloud-build/steps/build-cloud-build-uses-source-repo-relationships.ts new file mode 100644 index 00000000..40265df2 --- /dev/null +++ b/src/steps/cloud-build/steps/build-cloud-build-uses-source-repo-relationships.ts @@ -0,0 +1,40 @@ +import { + createDirectRelationship, + getRawData, + IntegrationStep, + RelationshipClass, +} from '@jupiterone/integration-sdk-core'; +import { cloudbuild_v1 } from 'googleapis'; +import { IntegrationConfig, IntegrationStepContext } from '../../../types'; +import { CloudBuildEntitiesSpec, CloudBuildStepsSpec } from '../constants'; + +export const buildCloudBuildUsesSourceRepositoryRelationshipsStep: IntegrationStep = + { + ...CloudBuildStepsSpec.BUILD_CLOUD_BUILD_USES_SOURCE_REPOSITORY_RELATIONSHIPS, + executionHandler: async function (context: IntegrationStepContext) { + const { jobState } = context; + + await jobState.iterateEntities( + { _type: CloudBuildEntitiesSpec.BUILD._type }, + async (buildEntity) => { + const rawBuild = getRawData(buildEntity); + + if (rawBuild?.source?.repoSource) { + const sourceEntity = await jobState.findEntity( + `projects/${rawBuild.source.repoSource.projectId}/repos/${rawBuild.source.repoSource.repoName}`, + ); + + if (sourceEntity) { + await jobState.addRelationship( + createDirectRelationship({ + _class: RelationshipClass.USES, + from: buildEntity, + to: sourceEntity, + }), + ); + } + } + }, + ); + }, + };