# GitLab: Set up a new project

This section shows the necessary steps to deploy a model in AIR using a template in GitLab.

In this article:

# Step 1: Create a new project

  1. Enter the necessary fields: Select air-template

  2. You have been given access to the Cognite GitLab repository - copy the files from there into your project folder.

# Step 2: Set up the GitLab project locally

  1. In the project folder, run poetry install and wait until all packages are installed (How to install poetry itself (opens new window))

  2. Run poetry run pre-commit install to use pre-commit hooks.

  3. Change the name of the folder in the functions folder. This will be the function that you are going to deploy to AIR.

# Step 3: Set up development and production tenants

  1. Edit .gitlab-ci.yml and set your dev (TEST_PROJECT) and prod tenants (PROD_PROJECT).
.variable_definitons: &variable_definitions
  variables:
    'FUNCTION_FOLDER': 'gapdetector' # name of function folder
    'TEST_PROJECT': 'my-dev-project' # name of test project - also define in repoconfig.yaml and set up secret in gitlab
    'PROD_PROJECT': 'my-prod-project' # name of prod project - also define in repoconfig.yaml and set up secret in gitlab
1
2
3
4
5
  1. Change the input of the FUNCTION_FOLDER variable to the exact name you renamed your folder in the previous section.

  2. Edit the repoconfig.yaml and add both your dev and prod project:

Projectproperties:
  my-dev-project: ['https://api.cognitedata.com', 'MY_DEV_API_KEY']
  my-prod-project: ['https://api.cognitedata.com', 'MY_PROD_API_KEY']
1
2
3

The URL is determined on which cluster your project is on. If in doubt, keep the default. You can choose the names for the variables MY_DEV_API_KEY and MY_DEV_API_KEY. Make sure that they are the same that you are going to set up in the next step.

# Step 4: Configure the GitLab project to deploy to AIR

The GitLab AIR repo requires the following secrets to be defined in GitLab (opens new window) (Settings > CICD > Variables). Make sure to clear Protect variable to ensure it is available to the CI/CD pipeline:

a) MY_DEV_API_KEY: This is your API key for the dev tenant.
b) MY_PROD_API_KEY: This is your API key for the prod tenant.

You defined both variables in the previous step.

Please make sure that your PROJECT_NAME_API_KEY has the permissions required to use Cognite Functions and AIR. The service account should have the group AIR Data Manipulation assigned to it. You or an administrator can check if this is the case in CDF (opens new window).

Last Updated: 11/2/2021, 7:56:54 AM