Automatic preview environments
If your service is one of many micro-services, after all your automatic tests on your service you would probably want to check the new service with your whole system. In this case you can launch the composition of your system as part of your build. At the end of this build you would be able to open the composition.
Pre-Requisites
You should already have done the tutorials for the basic pipeline and temporary environments.
Launching The Composition
- Open your
codefresh.yml
file and add a new step:
YAML
launch_composition_step:
title: "Launch full composition with latest images"
type: launch-composition
composition: your-composition-name
fail_fast: false
- Commit and push the changes to git repository
- Build your service with Codefresh
- Click on Compositions on the left sidebar and then choose the Running Compositions tab.
- You will see the new preview environment on this page
Launching an environment only on one branch
There is a limit to the number environments you can run concurrently. That’s why it’s a good practice to launch the the composition only on certain condition. Usually the most relevant condition is the branch, since you probably want your environment to be updated by you main branch.
The following instructions would explain how to launch the environment for only the master
branch:
- Open your
codefresh.yml
file and add to the ‘launch_composition_step` the following:
YAML
when:
branch:
only:
- master
- Commit and push changes to your git repository
master
branch.
- Build your service with codefresh on branch
master
- Create a new branch and push it to your git repository under a new branch
- Build your service with codefresh on the new branch
- When the build would finish, open the its log. You should see something like: