Gitlab Project Clone, Build - Cloud Function

Hi All,

Would need your inputs on below use case.

Build a cloud function

  1. Connect to Gitlab and check our specified branch or a tagged version of a project.

  2. Do a gradle build, from the generated artifacts (build directory) - consume few files which are required - extract some info - and then do a REST invocation of API to publish the extracted content.

Would like to run the above as an on-demand - by passing branch name or a tag version.

Will that be possible with a Cloud function so that I can invoke with a REST call -on demand

api /cloud-function/test?branch=mybranch123 or main

api /cloud-function/test?tag=0.0.1

Thanks.

As shown in this article, How to Set Up a Deployment Pipeline on Google Cloud with Cloud Build and Cloud Functions, you could use Cloud Build to build repositories from GitLab in combination with Cloud Functions.

Cloud Build is a service that executes your builds on Google Cloud Platform infrastructure. Cloud Build can import source code from Google Cloud Storage, Cloud Source Repositories, GitHub, or Bitbucket, execute a build to your specifications, and produce artifacts such as Docker containers or Java archives.> Cloud Build executes your build as a series of build steps, where each build step is run in a Docker container. A build step can do anything that can be done from a container irrespective of the environment. To perform your tasks, you can either use the supported build steps provided by Cloud Build or write your own build steps.

As outlined in the documentation about using community-contributed builders and custom builders, it shows how to use community-contributed builders and custom builders in Cloud Build. Also, the Cloud Build developer community provides open-source builders that you can use to execute your tasks.

Finally, after getting your Cloud Build pipeline configured as desired, you could use this package to trigger a Cloud Build pipeline using a Cloud Function as shown in this StackOverflow answer and pass a branch name to be compiled.