Obtaining the pipeline log for an environment

2 minute read

The CloudBees Previews API provides an endpoint that you can use to find a specific environment. You can also fetch the pipeline log for an environment. Before you can obtain an environment’s pipeline log, you must authenticate requests by providing the API token.

You can use a curl query similar to the following to fetch an environment’s pipeline log:

Fetching an environment’s pipeline log
$ curl -H 'X-Api-Token: <API_TOKEN>' \ (1)
	"<SERVER_ADDRESS>/api/v1/namespaces/<NAMESPACE>/environments/<NAME>/log"
# scm-checkout container logs:
environment-git 1.1.1: checkout https://github.com/mgoltzsche/sample-app-helm.git
Enumerating objects: 61, done.
Counting objects: 100% (61/61), done.
Compressing objects: 100% (45/45), done.
Total 61 (delta 22), reused 48 (delta 13), pack-reused 0


# target-dir-creation container logs:


# detector container logs:
{"app":"detector","level":"info","msg":"Writing target file /workspace/target/helm-values.yaml","time":"2021-09-13T18:33:13Z"}
{"app":"detector","level":"info","msg":"Interpolated .preview.yaml","time":"2021-09-13T18:33:13Z","yaml":"apiVersion: v1alpha1\navailableContexts:\n- default\ncontext: default\ndeployer:\n  args:\n  - deploy\n  env:\n  - name: ENV_RESOURCE_DIR\n    value: /workspace/target/k8s/manifest.yaml\n  image: cloudbees/environment-deployer:0.3.3\npipeline:\n- args:\n  - template\n  - /workspace/source/charts/sample-app\n  - --name=env-xyz\n  - --namespace=env-xyz\n  - --values=/workspace/target/helm-values.yaml\n  - --output=/workspace/target/k8s/manifest.yaml\n  image: cloudbees/environment-helm-generator:0.2.0\n  name: helm-template\nundeployer:\n  args:\n  - undeploy\n  image: cloudbees/environment-deployer:0.3.3\n"}
{"app":"detector","level":"info","msg":"Writing detection result to /detection-result/result.yaml","time":"2021-09-13T18:33:13Z"}


# status-updater container logs:
{"level":"info","ts":1631557995.0777693,"msg":"Reading detection result from /detection-result/result.yaml","environment":"default/env-xyz"}
{"level":"info","ts":1631557995.1012492,"msg":"Result written to Environment status","environment":"default/env-xyz"}


# step-helm-template container logs:
Running khelm 2.0.0-beta.6-e33800a (helm 3.5.4)
Rendering chart sample-app 0.0.1 with name "env-xyz" and namespace "env-xyz"


# deployer container logs:
{"app":"deployer","level":"info","msg":"Running environment-deployer","time":"2021-09-13T18:33:20Z","version":"0.3.3"}
{"app":"deployer","level":"info","msg":"creating namespace","namespace":"env-xyz","parentNamespace":"default","time":"2021-09-13T18:33:20Z"}
{"app":"deployer","expected":"Ok","level":"info","msg":"namespace has not reached expected state yet","namespace":"env-xyz","state":"","time":"2021-09-13T18:33:20Z"}
{"app":"deployer","expected":"Ok","level":"info","msg":"namespace has not reached expected state yet","namespace":"env-xyz","state":"Missing","time":"2021-09-13T18:33:20Z"}
{"app":"deployer","level":"info","msg":"namespace reached expected state","namespace":"env-xyz","state":"Ok","time":"2021-09-13T18:33:20Z"}
{"app":"deployer","clusterrole":"previews-deployer-childns-clusterrole","level":"info","msg":"Preparing child namespace ServiceAccount","serviceaccount":"env-xyz/deployer-sa","time":"2021-09-13T18:33:20Z"}
{"app":"deployer","inventory":"env-xyz/inventory-env-xyz","inventoryID":"faf24942-f524-4e7b-bfca-27bf9fc8479d","level":"info","msg":"Applying inventory","time":"2021-09-13T18:33:23Z"}
{"app":"deployer","evt":"status","kind":"Service","level":"info","msg":"Resource not found","resource":"env-xyz/app","status":"NotFound","time":"2021-09-13T18:33:23Z"}
{"app":"deployer","evt":"status","kind":"Deployment","level":"info","msg":"Resource not found","resource":"env-xyz/app","status":"NotFound","time":"2021-09-13T18:33:23Z"}
{"app":"deployer","evt":"status","kind":"Ingress","level":"info","msg":"Resource not found","resource":"env-xyz/app","status":"NotFound","time":"2021-09-13T18:33:23Z"}
{"app":"deployer","evt":"apply","kind":"Service","level":"info","msg":"Created","resource":"env-xyz/app","time":"2021-09-13T18:33:23Z","type":0}
{"app":"deployer","evt":"apply","kind":"Deployment","level":"info","msg":"Created","resource":"env-xyz/app","time":"2021-09-13T18:33:23Z","type":0}
{"app":"deployer","evt":"apply","kind":"Ingress","level":"info","msg":"Created","resource":"env-xyz/app","time":"2021-09-13T18:33:23Z","type":0}
{"app":"deployer","level":"info","msg":"ServersideApplied ApplyEventCompleted","time":"2021-09-13T18:33:23Z"}
{"app":"deployer","evt":"status","kind":"Service","level":"info","msg":"Service is ready","resource":"env-xyz/app","status":"Current","time":"2021-09-13T18:33:26Z"}
{"app":"deployer","evt":"status","kind":"Deployment","level":"info","msg":"Deployment is available. Replicas: 1","resource":"env-xyz/app","status":"Current","time":"2021-09-13T18:33:26Z"}
{"app":"deployer","evt":"status","kind":"ReplicaSet","level":"info","msg":"ReplicaSet is available. Replicas: 1","resource":"env-xyz/app-6db9655885","status":"Current","time":"2021-09-13T18:33:26Z"}
{"app":"deployer","evt":"status","kind":"Pod","level":"info","msg":"Pod is Ready","resource":"env-xyz/app-6db9655885-dvzcb","status":"Current","time":"2021-09-13T18:33:26Z"}
{"app":"deployer","evt":"status","kind":"Ingress","level":"warning","msg":"no load balancer assigned","resource":"env-xyz/app","time":"2021-09-13T18:33:26Z"}
{"app":"deployer","evt":"status","kind":"Ingress","level":"warning","msg":"no load balancer assigned","resource":"env-xyz/app","time":"2021-09-13T18:34:17Z"}
{"app":"deployer","level":"info","msg":"PruneEventCompleted","time":"2021-09-13T18:34:20Z"}
{"app":"deployer","level":"info","msg":"5 resources have been applied successfully","time":"2021-09-13T18:34:20Z"}
{"app":"deployer","level":"info","msg":"Public URL","time":"2021-09-13T18:34:20Z","url":"http://localhost/env-xyz"}
{"app":"deployer","level":"info","msg":"Writing deployment result to /deployment-result/result.yaml","time":"2021-09-13T18:34:20Z"}


# status-updater container logs:
Reading deployment result from /deployment-result/result.yaml
{"level":"info","ts":1631558061.5552042,"msg":"Result written to Environment status","environment":"default/env-xyz"}
1<SERVER_ADDRESS> must be substituted with the Helm chart’s value apiserver.ingress.host (defaults to api.<global.ingress.host>). <API_TOKEN> must be substituted with the API token that was configured with the apiserver.auth chart value. <NAMESPACE> must be substituted with the environment namespace. <NAME> must be substituted with the environment name.