CircleCI
You can use Shipyard's CircleCI orb to run jobs on ephemeral environments which were automatically deployed by Shipyard, authenticating into them via a bypass token. The orb connects with Shipyard during a workflow, fetching necessary environment variables in order to run E2E tests where authentication via OAuth is normally required.
How to use
In your CircleCI config, usually located in .circleci/
, you can use the Shipyard Orb as per the following example:
- Use CircleCI version 2.1 at the top of your
.circleci/config.yml
file.
version: 2.1
- Add the
orbs
stanza below your version, invoking the orb:
orbs:
shipyard: shipyard/shipyard@3.6.1
- Use Shipyard elements in your existing workflows and jobs.
- Opt-in to use of uncertified orbs on your organization’s Security settings page
Usage example
Collect the bypass token and URL for an authenticated ephemeral environment attached to this PR in order to run E2E tests on it. Please make sure that your SHIPYARD_API_TOKEN
is included as an environment variable.
version: '2.1'
orbs:
shipyard: shipyard/shipyard@1
jobs:
ephemeral-e2e-tests:
executor:
name: cypress/browsers-chrome77
steps:
- checkout
- shipyard/fetch-shipyard-env
- run:
command: |
export CYPRESS_BASE_URL=${SHIPYARD_ENVIRONMENT_URL}
export CYPRESS_BYPASS_TOKEN=${SHIPYARD_BYPASS_TOKEN}
npm run test
name: Run the e2e tests on the ephemeral environment
workflows:
use-my-orb:
jobs:
- ephemeral-e2e-tests
The fetch-shipyard-env
job can be configured using the following parameters:
Input name | Description | Required | Default Value | Type |
---|---|---|---|---|
api-token | Shipyard API token used to fetch necessary environment variables from Shipyard. | no | SHIPYARD_API_TOKEN | env_var_name |
timeout-minutes | # of minutes to wait for Shipyard environment before timing out | no | 60 | integer |
exit-if-not-pull-request | Gracefully exit CircleCI job if this job is not for a pull request | no | false | boolean |
app-name 1 | Filter the environments by name of the application on the Shipyard app | no | string |
On successful run, the following environment variables are set, which can then be passed on to other actions in the same workflow.
Parameter Name | Description |
---|---|
SHIPYARD_ENVIRONMENT_ID | ID of the ephemeral environment |
SHIPYARD_ENVIRONMENT_URL | URL of the ephemeral environment |
SHIPYARD_BYPASS_TOKEN 1 | Token to bypass authentication |
1 Available in v3.5.1+