Use Kosli in CI Systems #

This section provides how-to guides showing you how to use Kosli to report changes from different CI systems.

Note that all CLI command flags can be set as environment variables by adding the the KOSLI_ prefix and capitalizing them.

Defaulted Kosli command flags from CI variables #

The following flags are defaulted (which means you don't need to provide the flags, they'll be automatically set to values listed below) as follows in the CI systems below:

Flag Default
--azure-org-url ${SYSTEM_COLLECTIONURI}
Flag Default
--git-commit ${BITBUCKET_COMMIT}
--repository ${BITBUCKET_REPO_SLUG}
--bitbucket-workspace ${BITBUCKET_WORKSPACE}
Flag Default
--build-url ${CODEBUILD_BUILD_URL}
Flag Default
--commit ${GITHUB_SHA}
--git-commit ${GITHUB_SHA}
--repository ${GITHUB_REPOSITORY}
Flag Default
--build-url ${CI_JOB_URL}
--commit-url ${CI_PROJECT_URL}/-/commit/${CI_COMMIT_SHA}
--commit ${CI_COMMIT_SHA}
--git-commit ${CI_COMMIT_SHA}
--repository ${CI_PROJECT_NAME}
--gitlab-org ${CI_PROJECT_NAMESPACE}
Flag Default
--build-url ${CIRCLE_BUILD_URL}
--commit-url ${CIRCLE_REPOSITORY_URL}(converted to https url)/commit(s)/${CIRCLE_SHA1}
--git-commit ${CIRCLE_SHA1}
Flag Default
--git-commit ${BUILD_VCS_NUMBER}

Use Kosli in Github Actions #

To use Kosli in Github Actions workflows, you can use the kosli CLI setup action to install the CLI on your Github Actions Runner. Then, you can use all the CLI commands in your workflows.

GitHub Secrets #

Keep in mind that secrets in Github actions are not automatically exported as environment variables. You need to add required secrets to your GITHUB environment explicitly. E.g. to make kosli_api_token secret available for all cli commands as an environment variable use following:

  KOSLI_API_TOKEN: ${{ secrets.kosli_api_token }}

Example #

Here is an example Github Actions workflow snippet using kosli-dev/setup-cli-action running kosli create flow command:

    runs-on: ubuntu-latest
      KOSLI_API_TOKEN: ${{ secrets.MY_KOSLI_API_TOKEN }}
      KOSLI_ORG: my-org
      - name: setup kosli
        uses: kosli-dev/setup-cli-action@v2
      - name: create flow
        run: kosli create flow my-flow --template pull-request,artifact,test

For a complete example of a Github workflow using Kosli, please check the Kosli CLI's own workflow.

Use Kosli in Gitlab pipelines #

For a complete example of a Gitlab pipeline using Kosli, please check this cyber-dojo pipeline.