Creating google cloud build triggers using gcloud alpha commands - json

I am attempting to create a Google Cloud Build trigger for a github repository using gcloud alpha builds triggers create github. I have created a BuildTrigger json containing my trigger config. My end goal is to create a trigger for pull requests in github repositories, which is a small change to the json file.
My json file:
committrigger.json
{
"description": "Commit to master branch",
"name": "Master-Commit",
"tags": ["test-flask-server"],
"github": {
"owner": "zamerman",
"name": "github_zamerman_test-flask-server",
"push": {
"branch": "master"
}
},
"disabled": false,
"filename": "/cloudbuild.yaml"
}
My command to create the trigger: gcloud alpha builds triggers create github --trigger-config committrigger.json
The error I am getting:
ERROR: (gcloud.alpha.builds.triggers.create.github) FAILED_PRECONDITION: Repository mapping does not
exist. Please visit https://console.cloud.google.com/cloud-build/triggers/connect?project=429437829619
to connect a repository to your project
Help or advice of any kind would be welcome. Thank you.
gcloud alpha builds triggers create github --trigger-config committrigger.json --verbosity=debug:
DEBUG: Running [gcloud.alpha.builds.triggers.create.github] with arguments: [--trigger-config: "committrigger.json", --verbosity: "debug"]
DEBUG: (gcloud.alpha.builds.triggers.create.github) FAILED_PRECONDITION: Repository mapping does not exist. Please visit https://console.cloud.google.com/cloud-build/triggers/connect?project=429437829619 to connect a repository to your project
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 983, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 784, in Run
resources = command_instance.Run(args)
File "/usr/lib/google-cloud-sdk/lib/surface/builds/triggers/create/github.py", line 169, in Run
buildTrigger=trigger, projectId=project))
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/cloudbuild/v1/cloudbuild_v1_client.py", line 353, in Create
config, request, global_params=global_params)
File "/usr/bin/../lib/google-cloud-sdk/lib/third_party/apitools/base/py/base_api.py", line 731, in _RunMethod
return self.ProcessHttpResponse(method_config, http_response, request)
File "/usr/bin/../lib/google-cloud-sdk/lib/third_party/apitools/base/py/base_api.py", line 737, in ProcessHttpResponse
self.__ProcessHttpResponse(method_config, http_response, request))
File "/usr/bin/../lib/google-cloud-sdk/lib/third_party/apitools/base/py/base_api.py", line 604, in __ProcessHttpResponse
http_response, method_config=method_config, request=request)
HttpBadRequestError: HttpError accessing <https://cloudbuild.googleapis.com/v1/projects/gcplabzamerman/triggers?alt=json>: response: <{'status': '400', 'content-length': '263', 'x-xss-protection': '0', 'x-content-type-options': 'nosniff', 'transfer-encoding': 'chunked', 'vary': 'Origin, X-Origin, Referer', 'server': 'ESF', '-content-encoding': 'gzip', 'cache-control': 'private', 'date': 'Wed, 25 Sep 2019 22:45:52 GMT', 'x-frame-options': 'SAMEORIGIN', 'alt-svc': 'quic=":443"; ma=2592000; v="46,43",h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000', 'content-type': 'application/json; charset=UTF-8'}>, content <{
"error": {
"code": 400,
"message": "Repository mapping does not exist. Please visit https://console.cloud.google.com/cloud-build/triggers/connect?project=429437829619 to connect a repository to your project",
"status": "FAILED_PRECONDITION"
}
}
>
ERROR: (gcloud.alpha.builds.triggers.create.github) FAILED_PRECONDITION: Repository mapping does not exist. Please visit https://console.cloud.google.com/cloud-build/triggers/connect?project=429437829619 to connect a repository to your project

Their github integration is not working at the moment. You can instead use triggerTemplate key to specify the cloud source repository that is connected to your github repo.
Update your configtrigger.json to something along the lines of:
{
"description": "Commit to master branch",
"name": "Master-Commit",
"tags": ["test-flask-server"],
"triggerTemplate": {
"projectId": "your project id",
"repoName": "github_zamerman_github_zamerman_test-flask-server",
"dir": "./",
"branchName": "master"
},
"disabled": false,
"filename": "/cloudbuild.yaml"
}

Related

Packer custom image build failed with ssh authentication error

I'm trying to build custom image for AWS EKS managed node group, Note: my custom image (ubuntu) already has MFA and private key based authentication enabled.
I cloned github repository to build eks related changes from the below url.
git clone https://github.com/awslabs/amazon-eks-ami && cd amazon-eks-ami
Next i made few changes to run the make file
cat eks-worker-al2.json
{
"variables": {
"aws_region": "eu-central-1",
"ami_name": "template",
"creator": "{{env `USER`}}",
"encrypted": "false",
"kms_key_id": "",
"aws_access_key_id": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_access_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"aws_session_token": "{{env `AWS_SESSION_TOKEN`}}",
"binary_bucket_name": "amazon-eks",
"binary_bucket_region": "eu-central-1",
"kubernetes_version": "1.20",
"kubernetes_build_date": null,
"kernel_version": "",
"docker_version": "19.03.13ce-1.amzn2",
"containerd_version": "1.4.1-2.amzn2",
"runc_version": "1.0.0-0.3.20210225.git12644e6.amzn2",
"cni_plugin_version": "v0.8.6",
"pull_cni_from_github": "true",
"source_ami_id": "ami-12345678",
"source_ami_owners": "00012345",
"source_ami_filter_name": "template",
"arch": null,
"instance_type": null,
"ami_description": "EKS Kubernetes Worker AMI with AmazonLinux2 image",
"cleanup_image": "true",
"ssh_interface": "",
"ssh_username": "nandu",
"ssh_private_key_file": "/home/nandu/.ssh/template_rsa.ppk",
"temporary_security_group_source_cidrs": "",
"security_group_id": "sg-08725678910",
"associate_public_ip_address": "",
"subnet_id": "subnet-01273896789",
"remote_folder": "",
"launch_block_device_mappings_volume_size": "4",
"ami_users": "",
"additional_yum_repos": "",
"sonobuoy_e2e_registry": ""
After adding user and private key build getting failed with below error.
logs
amazon-ebs: Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain.
for me just changue region for aws o delete aws region in packer.

Get "HTTP Error: 404, Method not found." when running "firebase deploy --only functions" on Firebase Cloud Functions

I'm stuck with this problem since hours and I thought that maybe one of you encountered it before.
I get
Error: HTTP Error: 404, Method not found. when I run firebase deploy --only functions so I'm unable to deploy my last updates.
This happens with ALL my Firebase Cloud Functions projects
This does not happen with my Firebase Hostings
Here's what I get when I add --debug:
firebase deploy --only functions:onBookingCreated --debug
[2020-08-25T15:18:37.029Z] ----------------------------------------------------------------------
[2020-08-25T15:18:37.032Z] Command: /usr/local/Cellar/node/12.4.0/bin/node /usr/local/bin/firebase deploy --only functions:onBookingCreated --debug
[2020-08-25T15:18:37.032Z] CLI Version: 7.0.0
[2020-08-25T15:18:37.032Z] Platform: darwin
[2020-08-25T15:18:37.032Z] Node Version: v10.15.3
[2020-08-25T15:18:37.033Z] Time: Tue Aug 25 2020 17:18:37 GMT+0200 (Central European Summer Time)
[2020-08-25T15:18:37.034Z] ----------------------------------------------------------------------
[2020-08-25T15:18:37.044Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-08-25T15:18:37.044Z] > authorizing via signed-in user
[2020-08-25T15:18:37.044Z] [iam] checking project infinitytechnologies for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[2020-08-25T15:18:37.046Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/infinitytechnologies:testIamPermissions
permissions=[cloudfunctions.functions.create, cloudfunctions.functions.delete, cloudfunctions.functions.get, cloudfunctions.functions.list, cloudfunctions.functions.update, cloudfunctions.operations.get, firebase.projects.get]
[2020-08-25T15:18:37.814Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Tue, 25 Aug 2020 15:18:42 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, server-timing=gfet4t7; dur=622, alt-svc=h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":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", accept-ranges=none, transfer-encoding=chunked
=== Deploying to 'infinitytechnologies'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run build
> functions# build /Users/Ben/infinitytechnologies-functions/functions
> tsc
✔ functions: Finished running predeploy script.
[2020-08-25T15:18:48.982Z] > [functions] package.json contents: {
"name": "functions",
"scripts": {
"build": "tsc",
"buildRun": "tsc -w",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"main": "lib/index.js",
"dependencies": {
"#google-cloud/logging-winston": "^3.0.5",
"cors": "^2.8.5",
"express": "^4.17.1",
"firebase": "^7.19.0",
"firebase-admin": "^8.13.0",
"firebase-functions": "^3.0.0",
"googleapis": "^43.0.0",
"html-encoder-decoder": "^1.3.8",
"moment": "^2.24.0",
"moment-timezone": "^0.5.27",
"morgan": "^1.9.1",
"morgan-body": "^2.4.8",
"node-mailjet": "3.3.1",
"telegraf": "^3.30.1",
"tmp": "^0.1.0",
"winston": "^3.2.1"
},
"devDependencies": {
"#types/moment-timezone": "^0.5.12",
"typescript": "^3.7.4"
},
"private": true
}
i functions: ensuring necessary APIs are enabled...
[2020-08-25T15:18:48.983Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/cloudfunctions.googleapis.com/projectSettings/infinitytechnologies?view=CONSUMER_VIEW
[2020-08-25T15:18:48.984Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/runtimeconfig.googleapis.com/projectSettings/infinitytechnologies?view=CONSUMER_VIEW
[2020-08-25T15:18:49.689Z] <<< HTTP RESPONSE 404 x-debug-tracking-id=15822584760350287123;o=0, vary=X-Origin, Referer, Origin,Accept-Encoding, content-type=application/json; charset=UTF-8, date=Tue, 25 Aug 2020 15:18:54 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, alt-svc=h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":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", accept-ranges=none, transfer-encoding=chunked
[2020-08-25T15:18:49.689Z] <<< HTTP RESPONSE BODY code=404, message=Method not found., status=NOT_FOUND
Error: HTTP Error: 404, Method not found.
[2020-08-25T15:18:49.692Z] Error Context: {
"body": {
"error": {
"code": 404,
"message": "Method not found.",
"status": "NOT_FOUND"
}
},
"response": {
"statusCode": 404,
"body": {
"error": {
"code": 404,
"message": "Method not found.",
"status": "NOT_FOUND"
}
},
"headers": {
"x-debug-tracking-id": "15822584760350287123;o=0",
"vary": "X-Origin, Referer, Origin,Accept-Encoding",
"content-type": "application/json; charset=UTF-8",
"date": "Tue, 25 Aug 2020 15:18:54 GMT",
"server": "ESF",
"cache-control": "private",
"x-xss-protection": "0",
"x-frame-options": "SAMEORIGIN",
"alt-svc": "h3-29=\":443\"; ma=2592000,h3-27=\":443\"; ma=2592000,h3-T050=\":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\"",
"accept-ranges": "none",
"transfer-encoding": "chunked"
},
"request": {
"uri": {
"protocol": "https:",
"slashes": true,
"auth": null,
"host": "servicemanagement.googleapis.com",
"port": 443,
"hostname": "servicemanagement.googleapis.com",
"hash": null,
"search": "?view=CONSUMER_VIEW",
"query": "view=CONSUMER_VIEW",
"pathname": "/v1/services/cloudfunctions.googleapis.com/projectSettings/infinitytechnologies",
"path": "/v1/services/cloudfunctions.googleapis.com/projectSettings/infinitytechnologies?view=CONSUMER_VIEW",
"href": "https://servicemanagement.googleapis.com/v1/services/cloudfunctions.googleapis.com/projectSettings/infinitytechnologies?view=CONSUMER_VIEW"
},
"method": "GET"
}
}
}
[2020-08-25T15:18:49.693Z] <<< HTTP RESPONSE 404 x-debug-tracking-id=13898179262678311641;o=0, vary=X-Origin, Referer, Origin,Accept-Encoding, content-type=application/json; charset=UTF-8, date=Tue, 25 Aug 2020 15:18:54 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, alt-svc=h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":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", accept-ranges=none, transfer-encoding=chunked
[2020-08-25T15:18:49.693Z] <<< HTTP RESPONSE BODY code=404, message=Method not found., status=NOT_FOUND
Thanks for your help! :)
You're using a very old version (7.0.0) of the Firebase CLI. The latest is 8.9.0. Upgrade it by following the instructions to install it. If you installed with npm, then just run npm i -g firebase-tools. You should be diligent about keeping it up to date over time, as it changes frequently.
thanks for answering so quickly!
I tried to do that but I get this:
(base) Ben MBP:functions Ben$ npm install -g firebase-tools
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
/usr/local/Cellar/node/14.8.0/bin/firebase -> /usr/local/Cellar/node/14.8.0/lib/node_modules/firebase-tools/lib/bin/firebase.js
npm WARN ws#7.3.1 requires a peer of bufferutil#^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN ws#7.3.1 requires a peer of utf-8-validate#^5.0.2 but none is installed. You must install peer dependencies yourself.
+ firebase-tools#8.9.0
updated 1 package in 10.942s
(base) Ben MBP:functions Ben$ firebase -V
7.0.0
So the problem was with brew and its Cellar folder. I don't know why but it didn't work properly.
So I just deleted the Cellar folder, reinstalled node manually (not using brew) and I could update firebase-tools and everything is now working fine!
Thanks for your help!
I had the same issue. I installed NodeJS 12.18 and then fired below commands
npm install -g firebase firebase-tools
firebase init functions
Then copied all code files to this new functions folder. Updated package.json with necessary packages. This resolved my issue.

How to Move/Rename a file in TFS Source Control 2015, using the REST API?

I am trying to move files on our internal TFS using Python and the TFS REST API; the server appears to only support the API up-to version 2, but on MSDN I cannot find any docs for versions below v4.1.
The URL I'm posting to is https://<server>/tfs/<Collection>/<Project>/_apis/tfvc/changesets
Currently my best guess at the correct JSON body for the post request looks like this:
{
"comment": "moved file",
"changes": [{
"changeType": "rename",
"item": {
"path": "<filepath>",
"version": 468,
"sourceServerItem": "<filepath>"
}
}]
}
But i cannot get further than an HTTp error 400 bad request with the following message
{
"$id": "1",
"innerException": null,
"message": "Exactly one value for PathActions is required.\r\nParameter name: change.SourceServerItem",
"typeName": "System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"typeKey": "ArgumentException",
"errorCode": 0,
"eventId": 0
}
And for the life of me i cannot find any reference to PathActions on google, that is not for git instead of tfvc, or a correct way of providing a value for this item.
Does anybody have a way of renaming/moving files on a TFVC via a HTTP request?
It just occurred to me to do a rename using the TFS web interface and peek at the request sent by the browser.
Turns out this is the correct format:
{
"comment": "Moved File",
"changes": [
{
"changeType": 8,
"sourceServerItem": "<old path>",
"item": {
"path": "<new path>",
"version": 470
}
}
]
}

data is not receiving at Azure IoTHub?

I am using Azure Edge V1 with Ubuntu, I have created 1 IoT Hub with the name say X and then created 2 Devices say dev1 & dev2. After that I changed simulated_device_cloud_upload_lin.json file.
modules:
IotHub - "args": {
"IoTHubName": "X",
"IoTHubSuffix": "azure-devices.net",
"Transport": "MQTT",
"RetryPolicy": "EXPONENTIAL_BACKOFF_WITH_JITTER"}
mapping - "args": [
{
"macAddress": "01:01:01:01:01:01",
"deviceId": "dev1",
"deviceKey": "primary key of dev1"
},
{
"macAddress": "02:02:02:02:02:02",
"deviceId": "dev2",
"deviceKey": "Primary key of dev2"
} ] }
And then I go inside build folder and run command
./samples/simulated_device_cloud_upload/simulated_device_cloud_upload_sample ../samples/simulated_device_cloud_upload/src/simulated_device_cloud_upload_lin.json
And this start sending messages to IoT Hub, but when I checked to IoTHub with iothub-explorer it will show me error given below-
error receiving reply from Event hub management end point : undefined.
And also messages did not reach at IoT Hub.
Could you please tell me what have I done wrong?

Can't create image from tar.gz file in bucket

I'm trying to create a custom image using Console or gcloud, i.e. (Note: URLs are masked with [naURL] to get around URL posting limitation.):
$ gcloud compute images create debian-9-1-v20170810-1 --source-uri=https:[naURL]//storage.googleapis.com/[my bucket]/compressed-image.tar.gz
The command runs for about half an hour (i.e. 1800s) and then gives the following error:
ERROR: (gcloud.compute.images.create) Could not fetch resource:
- Did not create the following resources within 1800s: https:[naURL]//www.googleapis.com/compute/v1/projects/spherical-proxy-175708/global/images/debian-9-1-v20170810-1. These operations may still be underway remotely and may still succeed; use gcloud list and describe commands or https:[naURL]//console.developers.google.com/ to check resource state
The corresponding REST record accessible via Console>Compute Engine>Operations for the item reads:
{
"kind": "compute#operation",
"id": "5371669110648613089",
"name": "operation-1502320142020-5565a2a676da1-06d76920-4c86568d",
"operationType": "insert",
"targetLink": "https:[naURL]//www.googleapis.com/compute/v1/projects/spherical-proxy-175708/global/images/debian-9-1-v20170810-1",
"targetId": "3098231522309056737",
"status": "DONE",
"user": "andree.leidenfrost#gmail.com",
"progress": 100,
"insertTime": "2017-08-09T16:09:02.501-07:00",
"startTime": "2017-08-09T16:09:03.136-07:00",
"endTime": "2017-08-09T16:59:29.128-07:00",
"error": {
"errors": [
{
"code": "INTERNAL_ERROR",
"message": "Code: '8625676013601614622'"
}
]
},
"httpErrorStatusCode": 503,
"httpErrorMessage": "SERVICE UNAVAILABLE",
"selfLink": "https:[naURL]//www.googleapis.com/compute/v1/projects/spherical-proxy-175708/global/operations/operation-1502320142020-5565a2a676da1-06d76920-4c86568d"
}
Because the HTTP error is 503 "SERVICE UNAVAILABLE" I've tried a few times over the last couple of days but the problem persists.
I'm trying to follow the instructions in document Importing Boot Disk Images to Compute Engine.
Any help or hints how to debug further would be greatly appreciated!