Why does a git push on any Project trigger a build in Google Cloud Build (GitHub Apps)? - github

I want to enable the Google Cloud Build Github App in several Github projects.
So on the Google Cloud Build Github App, I click on grant this app access to your GitHub account
Then on the following screen, I install Google Cloud Build on All repositories.
Then I'm redirecting to a couple of Google Authorization screens.
Then I endup on the Google following screen, where I select an existing Google project-id then accept the consent screen.
The issue is: a git push on any of my Github repo triggers a build in this google project-id (and not on his related Google project-id)
Of course I want
a push in Github project#1 to trigger a build in Google Cloud Build project#1
a push in Github project#2 to trigger a build in Google Cloud Build project#2

There is now an "Add another project" button that allows you to connect repositories directly to different projects when setting up the Google Cloud Build connection.
See this screenshot:

I believe that's because the app works on the Account level and not on the project level.

Related

Github webhook is not created when creating a Google Cloud Build trigger

I have many projects which uses Google Cloud Build + Github build pipeline setup. However, there is this one project, which I cannot create a webhook in Github for.
It used to work - but commits to the repository doesn't trigger the build process any more. I deleted the trigger and added it again - but the webhook in Github is not created automatically for this project.
When I run the trigger manually, it picks the wrong, but fixed commit which I did before an year.
Any clue?
Could you try delete a repository on Cloud Source Repositories and setup Google Cloud Build again ?
See:
https://cloud.google.com/cloud-build/docs/running-builds/automate-builds
Note: For external repositories, such as GitHub and Bitbucket, you must have owner-level permissions for the Cloud Platform project with which you're working. When you set up a build trigger with an external repository for the first time, you'll need to set up authorization with that repository.
After you've set up your external repository, Cloud Source Repository creates a mirror of your repository.
https://source.cloud.google.com
https://cloud.google.com/source-repositories/docs/deleting-a-repository
https://cloud.google.com/source-repositories/docs/mirroring-a-github-repository
I am experiencing the same issue. I can create a trigger for a repo, but I cannot connect the repo automatically to cloud build. We also have many projects, and this manual labor is sort of annoying.
Is there any (under the hood) github/gcloud api available in which I can connect a github repo to cloud build? I am aware that this can only be done by someone with admin privileges on a repo or organization in github.
After this, I will be able to run the command gcloud build triggers create github [NAME]

Google Cloud Build GitHub App - auto trigger for all projects in organization

Up until a few weeks ago, when installing the Google Cloud Build GitHub app in a GitHub organization, it was possible to specify that all GitHub projects within that organization would create a build trigger.
Yesterday I noticed that this no longer happens, and new projects added to the GitHub organizations don't trigger a build and I can see a message on the specific commit saying that "this repository is not mapped to a Google Cloud platform project".
Is this an intentional change in spec - so one needs to manually link every new repo via the Console/API - or something I'm missing?
yes. for a new project, you have to manually set up on the cloud build page by "Connect repository". then you can use gcp cli comamnd set the trigger,
gcloud beta builds triggers create github

Google Cloud Builds Trigger for GitHub Repo says "No tag matches" Always

Build Trigger Setup
Setup a Build Trigger to a GitHub Repo
Trigger Type: Tag
Tag(regex): .*
Cloud Build Configuration file
Substitution variables:
_DEPLOYMENT_ENV: staging
The config is below:
Things I've Looked at
I've checked out the GitHub Applications and Authorizations. Google Cloud Platform is approved
The Google Cloud GitHub Marketplace Plugin is on for the repo and functions. I get a greencheck mark on pull requests after it builds the containers
Current Results and Expectation
I expect there to be tags matched because the repo has some tags. I push some new tags and nothing has changed.
Note: Google Cloud Build's GitHub Marketplace Plugin is still in Alpha, so its features are not reliable and it is not unusual to run into breaking changes... and there is no active support for it.
The screen you are seeing is from Google Cloud Platform -> Cloud Build -> Triggers. It is different and unrelated to the Google Cloud plugin found inside the GitHub Marketplace (I know, it is confusing).
The triggers you setup currently pull in GitHub repos into Google Cloud Source Repositories before your triggers are executed.
The GitHub plugin, I have been having some issues with it these few days and I think they are introducing some new breaking changes on it soon, but when it worked, it does not require any triggers and purely looks at the cloudbuild.yaml file to do builds automatically. I had to create separate scripts inside the cloudbuild.yaml to setup different build based on tags / branches (Cloud Build Triggers let you do all these inside the UI), but what you get as part of the GitHub plugin is this "GitHub Checks Events" (the green check / red cross) next to the corresponding commits in GitHub and also a very brief details page. The GitHub plugin is currently acting weird on me and I am in the process of switching over to use Cloud Build Triggers until they have sorted it out.
I think they are working on something to bridge the difference between Google Cloud Build Triggers and the Cloud Build GitHub plugin... just a feeling from the current log messages I see inside Cloud Build...

Cloud Build Trigger Settings have stale, out-of-date GitHub branch data

We installed the Google Cloud Build GitHub app. We then created some Build Triggers with the Google Cloud Build web user interface. This worked for a while.
Recently we pushed new branches to our GitHub repositories and tried to create Google Cloud Build Triggers for those branches. The Trigger Settings page says "No branch matches" even though we are 100% sure that the branch exists on GitHub.
How can we refresh the branch listings in the Google Cloud Build Trigger Settings page?
We have tried logging in/out of Google Cloud Build and GitHub. We have also tried uninstalling and re-installing the Google Cloud Build GitHub app. We have also tried simply waiting for a few hours.
The problem was that, while configuring Cloud Build with GitHub, we had pushed too many buttons.
This is an overview of what we needed to reset.
In GitHub
Go to the affected repository.
Open its settings.
Delete the Webhook associated with source.developers.google.com/webhook/github.
Delete the Deploy key associated with Google Connected Repository Fingerprint.
In Google Cloud Console (console.cloud.google.com)
Open Source Repositories
Disconnect the mirror of the affected repository.
Open Cloud Build
Delete and recreate the Build Trigger(s) for the affected repository.
Aside re: the Google Cloud Build GitHub App
Setting up specific triggers in Google Cloud Build is orthogonal to using the Google Cloud Build GitHub app. The former does not require the latter. They are different ways to do similar things.
If you had installed the Google Cloud Build GitHub App in your GitHub account because you thought it was required for Google Cloud Build Triggers, then uninstall the Google Cloud Build GitHub App. It works differently than setting up specific Google Cloud Build triggers does, and I found it quite confusing to have both running.

Deploy meanjs based application hosted in Github to Bluemix

My application using meanjs framework is hosted in Github repository. How do I integrate Bluemix and Git to deploy my application to Bluemix?
Your best option for using Git to deploy to Bluemix from a Github repository is to use this link:
https://bluemix.net/deploy?repository=LINK-TO-YOUR-GITHUB-REPO
This will grab your repository, launch a Bluemix application with it and create a Bluemix DevOps project that allows you to push changes to your application with Git instead of the Cloud Foundry CLI tool.
You can also manually perform this process by starting here (https://hub.jazz.net/create). On this setup page, be sure to select 'Make this a Bluemix Project' so you can deploy your code to Bluemix.
FYI - Just deploying a repository to Bluemix does not mean that it will run on the platform. See here for more info on getting your code to work on Bluemix.
Deploy the project into Bluemix as below:
download meanjs from Github at: https://github.com/meanjs/mean
install dependency packages by npm -install
check and see if the project can run at local by command grunt as meansjs project describes
create a mongolab service in Bluemix with named mean-mongo
check .cfignore file contains below items;
List of files and directories to ignore when deploying to Bluemix (.DS_Store, .nodemonignore, .sass-cache/, npm-debug.log, node_modules/, public/lib, app/tests/coverage/, .bower-*/, .idea/)
push the application by cf push <appname> -p .
Integrate the app to Git
make sure that step 1 completes successfully, and the application is upload to Bluemix successfully
add the app deployed to Bluemix in step 1 to jazz hub by (click the app -> click "ADD GIT" at upper right of the app - > then it will create url to the jazz hub project
login onto jazz hub by clicking "GIT URL" or "EDIT" button at the app page
it will open jazz hub page
further reference
http://www.ibm.com/developerworks/cloud/library/cl-intro1-app/