Skip to content

gcloud setup package pipeline

devonfw-core edited this page Dec 30, 2022 · 4 revisions

Setting up a Package pipeline on Google Cloud

In this section we will create a package pipeline to build and push a container image of the project application into the specified container registry. This pipeline will be configured to be triggered after the package pipeline on branches develop or release/*. It consumes the artifact produced by the build pipeline.

The creation of the pipeline will follow the project workflow, so a new branch named feature/package-pipeline will be created and the YAML file for the pipeline will be pushed to it.

Then, the new branch will be merged into the appropriate branch (provided in -b flag).

The script located at /scripts/pipelines/gcloud/pipeline_generator.sh will automatically create this new branch, create a package pipeline based on a YAML template, create the Pull Request and, if it is possible, merge this new branch into the specified branch.

Prerequisites

This script will commit and push the corresponding YAML template into your repository, so please be sure your local repository is up-to-date (i.e you have pulled latest changes with git pull).

Creating the pipeline using provided script

Usage

pipeline_generator.sh \
  -c <config file path> \
  -n <{pipeline_type} name> \
  -l <language or framework> \
  --dockerfile <dockerfile path> \
  -d <project local path> \
  --build-pipeline-name <build {pipeline_type} name> \
  --quality-pipeline-name <quality {pipeline_type} name> \
  -i <image name> \
  [--language-version <version>] \
  [--registry-location <registry location>] \
  [--flutter-web-platform] \
  [--flutter-android-platform] \
  [-u <registry user>] \
  [-p <registry password>] \
  [--aws-access-key <aws access key>] \
  [--aws-secret-access-key <aws secret access key>] \
  [--aws-region <aws region>] \
  [--quality-pipeline-name <quality {pipeline_type} name>] \
  [-b <branch>] \
  [-m <machine type for {pipeline_type} runner>] \
  [--flutter-web-renderer <auto (default), canvaskit, html>]
  [--env-vars <env vars list>]
  [--secret-vars <secret vars list>]
Note
The config file for the package pipeline is located at /scripts/pipelines/gcloud/templates/package/package-pipeline.cfg.

Flags

-c, --config-file              [Required] Configuration file containing {pipeline_type} definition.
-n, --pipeline-name            [Required] Name that will be set to the {pipeline_type}.
-l, --language                 [Required, if dockerfile not set] Language or framework of the project.
    --dockerfile               [Required, if language not set] Path from the root of the project to its Dockerfile. Takes precedence over the language/framework default one.
-d, --local-directory          [Required] Local directory of your project.
    --build-pipeline-name      [Required] Build {pipeline_type} name.
    --quality-pipeline-name    [Required] Quality {pipeline_type} name.
-i, --image-name               [Required] Name (excluding tag) for the generated container image.
--language-version             [Required, if Flutter or Python] Language or framework version.
--registry-location            [Required, if Flutter] Artifact registry location.
--flutter-web-platform         [Required, if Flutter] Compile Web platform.
--flutter-android-platform     [Required, if Flutter] Compile Android platform.
-u, --registry-user            [Required, unless AWS or GCP] Container registry login user.
-p, --registry-password        [Required, unless AWS or GCP] Container registry login password.
    --aws-access-key           [Required, if AWS] AWS account access key ID. Takes precedence over registry credentials."
    --aws-secret-access-key    [Required, if AWS] AWS account secret access key."
    --aws-region               [Required, if AWS] AWS region for ECR."
    --quality-pipeline-name               Quality {pipeline_type} name.
-b, --target-branch                       Name of the branch to which the Pull Request will target. PR is not created if the flag is not provided.
-m, --machine-type                        Machine type for {pipeline_type} runner. Accepted values: E2_HIGHCPU_8, E2_HIGHCPU_32, N1_HIGHCPU_8, N1_HIGHCPU_32.
    --flutter-web-renderer                Flutter web renderer. Accepted values: auto (default), canvaskit, html.
    --env-vars                            List of environment variables to be made available in pipeline. Syntax: "var1=val1 var2=val2 ...".
    --secret-vars                         List of environment variables (saved as secrets in Secret Manager) to be made available in pipeline. Syntax: "var1=val1 var2=val2 ...".

Examples

Quarkus project

Generic container registry
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n quarkus-project-package -l quarkus -d C:/Users/$USERNAME/Desktop/quarkus-project -i username/quarkus-project -u username -p password {extra_args_quarkus} -b develop -w
AWS ECR
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n quarkus-project-package -l quarkus -d C:/Users/$USERNAME/Desktop/quarkus-project -i username/quarkus-project --aws-access-key AKIAIOSFODNN7EXAMPLE --aws-secret-access-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY --aws-region eu-west-1 {extra_args_quarkus} -b develop -w

Node.js project

Generic container registry
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n node-project-package -l node -d C:/Users/$USERNAME/Desktop/node-project -i username/node-project -u username -p password {extra_args_node} -b develop -w
AWS ECR
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n node-project-package -l node -d C:/Users/$USERNAME/Desktop/node-project -i username/node-project --aws-access-key AKIAIOSFODNN7EXAMPLE --aws-secret-access-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY --aws-region eu-west-1 {extra_args_node} -b develop -w
==== Angular project
Generic container registry
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n angular-project-package -l angular -d C:/Users/$USERNAME/Desktop/angular-project --build-pipeline-name angular-project-build --quality-pipeline-name angular-project-quality -i username/angular-project -u username -p password -b develop -w
AWS ECR
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n angular-project-package -l angular -d C:/Users/$USERNAME/Desktop/angular-project --build-pipeline-name angular-project-build --quality-pipeline-name angular-project-quality -i username/angular-project --aws-access-key AKIAIOSFODNN7EXAMPLE --aws-secret-access-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY --aws-region eu-west-1 -b develop -w

Python project

Generic container registry
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n python-project-package -l python -d C:/Users/$USERNAME/Desktop/python-project {extra_args_python} -i username/python-project -u username -p password -b develop -w
AWS ECR
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n python-project-package -l python -d C:/Users/$USERNAME/Desktop/python-project {extra_args_python} -i username/python-project --aws-access-key AKIAIOSFODNN7EXAMPLE --aws-secret-access-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY --aws-region eu-west-1 -b develop -w
Google Cloud Artifact Registry
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n python-project-package -l python -d C:/Users/$USERNAME/Desktop/python-project {extra_args_python} -i eu-southwest1-docker.pkg.dev/username/python-project -b develop -w

Flutter project

Web platform
Generic container registry
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n flutter-project-package -l flutter -d C:/Users/$USERNAME/Desktop/flutter-project {extra_args_flutter} {extra_args_flutter_web} -i username/flutter-project -u username -p password -b develop -w
AWS ECR
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n flutter-project-package -l flutter -d C:/Users/$USERNAME/Desktop/flutter-project {extra_args_flutter} {extra_args_flutter_web} -i username/flutter-project --aws-access-key AKIAIOSFODNN7EXAMPLE --aws-secret-access-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY --aws-region eu-west-1 -b develop -w
Google Cloud Artifact Registry
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n flutter-project-package -l flutter -d C:/Users/$USERNAME/Desktop/flutter-project {extra_args_flutter} {extra_args_flutter_web} -i eu-southwest1-docker.pkg.dev/username/flutter-project -b develop -w
Android platform: Google Cloud Artifact Registry
./pipeline_generator.sh -c ./templates/package/package-pipeline.cfg -n flutter-project-package -l flutter -d C:/Users/$USERNAME/Desktop/flutter-project {extra_args_flutter} {extra_args_flutter_android} -b develop -w

Guides per provider

Clone this wiki locally