We use Google Cloud Build (GCB) triggers to test applications.
For more information, see the
gcloud alpha builds triggers
commands.
The following sections are concerned to Kubernetes apps.
-
Make a copy of an existing config file:
cp k8s/mariadb-galera.yaml "k8s/$APP_NAME.yaml" sed -i "s/mariadb-galera/$APP_NAME/g" "k8s/$APP_NAME.yaml" sed -i '/^\s\sinstallationId/d' "k8s/$APP_NAME.yaml" sed -i '/^id/d' "k8s/$APP_NAME.yaml"
-
Open the config file and verify that everything looks correct:
cat "k8s/$APP_NAME.yaml"
-
Run the following command to create a trigger for your Kubernetes application:
gcloud alpha builds triggers create github \ --trigger-config k8s/$APP_NAME.yaml \ --project $PROJECT_ID
Where:
$APP_NAME
is the application name for which you want to create a trigger.$PROJECT_ID
is the GCP project ID of the project where the trigger will be created.
-
Mark the newly created trigger as required in the GitHub repository settings. For more information, see the enabling required status checks documentation.
NOTE: The trigger must be triggered initially before it is available in the list.
-
Run the following command to update a trigger for your Kubernetes application:
NOTE: You can only update an existing trigger if its configuration file contains either that trigger's name or trigger ID. If neither are present within the configuration file, a new trigger will be created.
gcloud alpha builds triggers import \ --source k8s/$APP_NAME.yaml \ --project $PROJECT_ID
Where:
$APP_NAME
is the application name for which you want to update the trigger.$PROJECT_ID
is the GCP project ID of the project where the trigger will be updated.
-
Run the following command to export an existing trigger to a file for your Kubernetes application:
gcloud alpha builds triggers export $TRIGGER \ --destination k8s/$APP_NAME.yaml \ --project $PROJECT_ID
Where:
$TRIGGER
is a trigger's ID or fully qualified identifier.$APP_NAME
is the name of the application whose configuration you want to export.$PROJECT_ID
is the GCP project ID of the project where the trigger will be exported.
-
Run the following command to get details of an existing trigger:
gcloud alpha builds triggers list \ --filter="filename:cloudbuild-k8s.yaml AND substitutions._SOLUTION_NAME:$APP_NAME" \ --project $PROJECT_ID