Trigger builds in CircleCI from a container, downloading artifacts on successful build
First, create a secret with your CircleCI token:
docker secret create circleci -
Then, add the following step to your pipeline:
steps:
circleci:
tasks:
- image: pipekit/circleci
secrets:
- source: circleci
target: token
Artifacts are automatically downloaded to /run/context/artifacts.
$REPOSITORY: (default: autodetected from context) the name of the GitHub repository in namespace/name format$REVISION: (default: autodetected from context) the commit hash to test$BRANCH: (default: none) the name of the branch to test$VCS_TYPE: github (default) or bitbucket$CONTEXT: (default: /run/context) where to find the project for automatic detection of repository name and revision$ARTIFACTS_PATH: (default: $CONTEXT/artifacts) where to download artifacts to$TOKEN_FILE: (default: /run/secrets/token) path to the file with the CircleCI API token$TOKEN: (default: none) the token to use (not recommended, use secrets instead)$READ_ONLY: (default: false) set to true to prevent triggering a new build, and instead look for a build that matches the commitUsing a branch name:
docker run --rm -it -e TOKEN=<token> -e REPOSITORY=<namespace/name> -e BRANCH=<branch> pipekit/circleci
Using a revision:
docker run --rm -it -e TOKEN=<token> -e REPOSITORY=<namespace/name> -e REVISION=<hash> pipekit/circleci
Automatically detecting the revision and repository names from a local project:
docker run --rm -it -e TOKEN=<token> -v $(pwd):/run/context pipekit/circleci
This will use the origin remote as $REPOSITORY, and the current checked out revision for $REVISION.
In order to fetch artifacts locally, add -v $(pwd):/run/context to the above command.
Other available environment variables:
$VCS_TYPE: github (default) or bitbucket$CONTEXT: (default: /run/context) where to find the project for automatic detection of repository name and revision$ARTIFACTS_PATH: (default: $CONTEXT/artifacts) where to download artifacts toThe $TOKEN can also be passed in as a secret, but you need to run the image as a service:
docker service create --restart-condition none --secret source=circleci,target=token [...] pipekit/circleci
Content type
Image
Digest
Size
5.1 MB
Last updated
about 9 years ago
docker pull pipekit/circleci