Use Kosli in CI Systems

Use Kosli in CI Systems #

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

Defaulted Kosli command flags from CI variables #

The following flags are defaulted as follows in the CI list below:

FlagDefault
--build-urlhttps://bitbucket.org/${BITBUCKET_WORKSPACE}/${BITBUCKET_REPO_SLUG}/addon/pipelines/home#!/results/${BITBUCKET_BUILD_NUMBER}
--commit-urlhttps://bitbucket.org/${BITBUCKET_WORKSPACE}/${BITBUCKET_REPO_SLUG}/commits/${BITBUCKET_COMMIT}
--commit${BITBUCKET_COMMIT}
--git-commit${BITBUCKET_COMMIT}
--repository${BITBUCKET_REPO_SLUG}
--bitbucket-workspace${BITBUCKET_WORKSPACE}
FlagDefault
--build-url${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
--commit-url${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}
--commit${GITHUB_SHA}
--git-commit${GITHUB_SHA}
--repository${GITHUB_REPOSITORY}
--github-org${GITHUB_REPOSITORY_OWNER}
FlagDefault
--git-commit${BUILD_VCS_NUMBER}

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.

Here is an example Github Actions workflow snippet using the Kosli declare pipeline command:

jobs:
  example:
    runs-on: ubuntu-latest
    env:
      KOSLI_API_TOKEN: ${{ secrets.MY_KOSLI_API_TOKEN }}
      KOSLI_OWNER: my-org
    steps:
      - name: setup kosli
        uses: kosli-dev/setup-cli-action@v1
      - name: declare pipeline
        run: kosli pipeline declare --pipeline my-pipeline -t pull-request,artifact,test
Note that all CLI command flags can be set as environment variables by adding the the KOSLI_ prefix and capitalizing them. In the example above, both --api-token and --owner flags were set from environment variables.

Defaulted CLI flags in Github Actions #

The following commands flags are defaulted when the Kosli CLI is run inside a Github Actions workflow:

FlagDefault
--build-url${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
--commit-url${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}
--commit${GITHUB_SHA}
--git-commit${GITHUB_SHA}
--repository${GITHUB_REPOSITORY}
--github-org${GITHUB_REPOSITORY_OWNER}