|
78 | 78 | KOSLI_API_TOKEN: ${{ secrets.kosli_api_token }} |
79 | 79 | ``` |
80 | 80 |
|
| 81 | +## I'm running the Kosli CLI in a subshell and the captured output includes stderr! |
| 82 | + |
| 83 | +The Kosli CLI writes debug information to `stderr`, and all other output to `stdout`. |
| 84 | +Normally, in a bash $(subshell), only `stdout` is captured. |
| 85 | +In the following example, the `DIGEST` variable captures _only_ the 64 character digest of the docker image; |
| 86 | +the extra debug information is printed to the terminal. |
| 87 | + |
| 88 | +```shell {.command} |
| 89 | +# In a local terminal |
| 90 | +KOSLI_DEBUG=true |
| 91 | +DIGEST="$(kosli fingerprint "${IMAGE_NAME}" --artifact-type=docker)" |
| 92 | +
|
| 93 | +[debug] calculated fingerprint: 2c6079df58292ed10e8074adcb74be549b7f841a1bd8266f06bb5c518643193e for artifact: 244531986313.dkr.ecr.eu-central-1.amazonaws.com/exercises-start-points:86f9052 |
| 94 | +
|
| 95 | +echo "DIGEST=${DIGEST}" |
| 96 | +DIGEST=2c6079df58292ed10e8074adcb74be549b7f841a1bd8266f06bb5c518643193e |
| 97 | +``` |
| 98 | + |
| 99 | +However, in many CI workflows (including Github and Gitlab), `stdout` and `stderr` are multiplexed together. |
| 100 | +This means `DIGEST` will contain _both_ the 64 character digest _and_ the debug information. |
| 101 | +For example: |
| 102 | + |
| 103 | +```shell {.command} |
| 104 | +# In a CI workflow |
| 105 | +KOSLI_DEBUG=true |
| 106 | +DIGEST="$(kosli fingerprint "${IMAGE_NAME}" --artifact-type=docker)" |
| 107 | +
|
| 108 | +echo "DIGEST=${DIGEST}" |
| 109 | +DIGEST=[debug] calculated fingerprint: 2c6079df58292ed10e8074adcb74be549b7f841a1bd8266f06bb5c518643193e for artifact: 244531986313.dkr.ecr.eu-central-1.amazonaws.com/exercises-start-points:86f9052 |
| 110 | +2c6079df58292ed10e8074adcb74be549b7f841a1bd8266f06bb5c518643193e |
| 111 | +``` |
| 112 | + |
| 113 | +When running the Kosli CLI in a subshell, in a CI workflow, we recommend explicitly setting the `--debug` flag to false. |
| 114 | + |
| 115 | +```shell {.command} |
| 116 | +# In a CI workflow |
| 117 | +KOSLI_DEBUG=true |
| 118 | +DIGEST="$(kosli fingerprint "${IMAGE_NAME}" --artifact-type=docker --debug=false)" |
| 119 | +
|
| 120 | +echo "DIGEST=${DIGEST}" |
| 121 | +DIGEST=2c6079df58292ed10e8074adcb74be549b7f841a1bd8266f06bb5c518643193e |
| 122 | +``` |
| 123 | + |
| 124 | + |
81 | 125 | ## Where can I find API documentation? |
82 | 126 |
|
83 | 127 | Kosli API documentation is available for logged in Kosli users here: https://app.kosli.com/api/v2/doc/ |
|
0 commit comments