How to connect Google Cloud Source Repo with Codemagic? - flutter

Codemagic is a build service for flutter applications it has built in support for bitbucket, github, etc. However it also supports linking repositories from other sources. To set this up you they ask you for a specificish format. URL should be in the following format: https://example.com/username/repo.git or git#example.com/username/repo.git.
I'm trying to figure out how to provide a url for my google cloud source repo in this format. I've tried this https://source.developers.google.com/p/[project-name]/r/[repo-name/ but then it complains about credentials. If I use the 'git#source.developers.google.com/.....' format I get an option to load an ssh key to authenticate and that passes verification but it doesn't correctly register/see the repo at the endpoint so something is off.
Anyone ever done this before. I've seen something about signed urls with google cloud and thought maybe I could use the https: format both make a signed url though everything i've seen with signed urls has to do with cloud storage and not cloud source.

I was able to add Google Cloud Source Repo to Codemagic using next link
ssh://mikhail#example.com#source.developers.google.com:2022/p/woven-voyage-xxxxx/r/test
You need also register your SSH key https://source.cloud.google.com/user/ssh_keys?register=true

In addition to #Mikhil Tokarev's answer,
You need to add a webhook manually after adding the Google source repository.
Please see my answer detailed instruction in this thread https://stackoverflow.com/a/63362923/11082769

Related

Is there a way to get the URL of the Google App Engine instance of a project in the GitHub PR flow?

We'd like for the PR approval for an application created in Google App Engine to return the project version URL to display in GitHub (so this can be passed on to the test team as a standalone entity). Not sure if this is actually possible. Has anyone had any luck doing this before?
So far, I have not been able to find any documentation for this, although plenty helping to connect GitHub processes to GCP.

Automate mirroring GitHub to GCP Source Repository?

We run Google Cloud Functions (python), which require to be deployed from Google Cloud Source Repository. Since all the code is stored on GitHub we resort to first mirroring GitHub into Source Repository. Although this only requires a few mouse clicks, it becomes a burden to repeat over 3+ projects (dev, staging, production) times 5+ repos (5+ apps).
I am looking to automate the mirroring config, preferably to add into the Terraform automation we already use, into a hands-off project configuration. Does the Google API support this mirroring automation? So far on my Google Cloud expedition everything was available in their API!
I fail to find Terraform examples though, and would appreciate a tip.
Come to think of it, if I can take Source Repository out of the equation, that would be just fine with me too. After all, I only use it as a pass-through / empty shell.
The Cloud Source Repository API includes a Repo resource that has a Mirror Config object where you could type in your Github's URL, webhook and credentials to automate this procedure. I would initially test it with the create method, but if you have an existing Cloud Source Repository I believe the patch method will also be worth exploring.
Additionally, there is an open Feature Request in order to connect a repository via the Cloud Build GitHub App that I recommend you to star and follow, as it could further ease your automation needs.

Can Gitlab expose build and coverage badges to anonymous users?

We are hosting some repository on GitHub, some other on GitLab.
Sometimes, the package is published but not the source code.
We always display build status and code coverage in README.md.
Is there a way to have build and coverage badge on GitLab always accessible to anonymous?
Since release 11.4.8 of Gitlab it's not possible to expose project's Badges through a Personnal Access Token anymore. Because of the change "
Restrict Personal Access Tokens to API scope on web requests."
The commit that removed this "workaround" was published as a security fix
An ongoing issue is currently being discussed to find another solution. Let's see how it goes.
That was followed by issue 13324
It includes:
FYI, I have a workaround for this using the GitLab API.
It assumes you have created a token in GitLab for a user (Note: That "user" needn't necessarily be Human - my use case is to display a badge on a dashboard hosted on a different VM).
<img src="https://<gitlab-uri>/<namespace>/<project>/badges/<branch>/build.svg?private_token=<token>
Update Dec. 2018: This is no loger possible through a token (see Paul B.'s answer).
This is because of "Improper Enforcement of Token Scope":
The GitLab web interface was vulnerable to an authorization issue that allowed access to the web-UI as a user using their Personal Access Token (PAT) of any scope.
The issue is now mitigated in the latest release and is assigned CVE-2018-19569.
But...:
Updated: 2018-11-28: We have received reports that this change has impacted how repo files and job artifacts are downloaded for some users.
For instructions on how to do so through the API, please see our support issue.
And you also have a current workaround which repeats the API access:
It is possible to add the project avatar to the project repository with a particular filename (logo) and then this file will be used for the avatar. There is an example here:
https://gitlab.com/issue-reproduce/project-avatar-repo
You'll be able to retrieve the files through the Repository Files API:
https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository
Example:
https://gitlab.com/api/v4/projects/issue-reproduce%2Fproject-avatar-repo/repository/files/logo.png?ref=master

Cloud foundry push from URL

There is option to push the application from git URL or any URL
using the CF Client (I mean via code) ?
Here there is documentation how to push from path
http://cli.cloudfoundry.org/en-US/cf/push.html
Neither the cf CLI, nor the Java client, nor the Cloud Controller API currently accept a git URL (or any other URL) to download the application bits into Cloud Foundry.
The --path option on cf push only accepts paths on your local filesystem.
If we were to support this (the topic has come up once or twice), it may make most sense for the Cloud Controller to expose an API for it, so that it can be supported by all CF clients in the same way. With this approach, CF can also be smarter about updates: it can check the git sha to know whether new bits need to be downloaded.
An issue with the current APIs for the CLI is that the CLI would first need to download the app bits from the URL and then upload it to CF, which seems inefficient. It would not be any faster than git clone https://github.com/example/app && cf push myapp -p app (apart from saving you a handful of keystrokes).
As far as I am aware cf client does not support direct deployment via code relying on CI/CD systems for this.
Some helpful links for research and discuss it:
Project manager/lead for CF CLI project - Dies Köper
( https://www.cloudfoundry.org/projects/ -> CLI )
#cli on cloudfoundry.slack.com
Tracker on https://www.pivotaltracker.com/n/projects/892938

Upload/Update XSP application to Bluemix through Cloud Foundry API

I'm using Cloud Foundry API to modify apps on IBM Bluemix.
I got oauth key and succeeded in calling simple REST requests, like v2/apps.
However, as I want to update XSP application I need to send a nsf file to bluemix.
I tried to use /v2/apps/:guid request, but according to documentation I can only send application parameters, but I cannot send whole application file.
Is there an endpoint to do that?
There is also an API to Upload the bits for an App, but if my understanding is correct what you are asking is basically to emulate a cf push via REST API. Please note that cf push is complex and is not something that is recommended recreating via API on Cloud Foundry. I don't know what your requirements are, but I'd suggest you to use cf push to do that. Anyway if you want more information on what are the steps it performs (from an high level perspective) you can take a look here. I suggest you also to see this Github Cloud Foundry issue where the user is trying to programmatically recreate the cf push.