Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 74 additions & 33 deletions deployment/ci-cd-license-key.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,32 @@ position: 7

# Telerik License Key in CI/CD Environment

This article describes how to set up and activate your [Telerik UI for Blazor license key](slug:installation-license-key) across a few popular CI/CD services by using environment variables.
This article describes how to set up and activate your [Telerik UI for Blazor license key](slug:installation-license-key) across a few popular cloud build CI/CD services. You can find guidance and examples on how to set environment variables for some of the most popular CI/CD platforms.

@[template](/_contentTemplates/common/get-started.md#license-key-version)

## Basics

The Telerik license activation process in a CI/CD environment involves the following steps:
The Telerik license activation process in CI/CD environments involves the following steps:

1. Go to the [License Keys page](https://www.telerik.com/account/your-licenses/license-keys) in your Telerik account and download your license key.
1. Set your license key value as an [environment variable](#creating-environment-variables) with a name `TELERIK_LICENSE`. In specific cases you may need to [use a license file](#using-license-file) instead.
1. Set an environment variable with either of the following names:
* `TELERIK_LICENSE`—the value must be the Telerik license key string.
* `TELERIK_LICENSE_PATH`—the value must be the full path to the license key file, including the license file name itself. `TELERIK_LICENSE_PATH` requires `Telerik.Licensing` version `1.4.9` and above. You can use it with Telerik UI for Blazor `8.1.0` and above.

## Creating Environment Variables
In most cases, the recommended way to provide your license key to the `Telerik.Licensing` NuGet package in CI/CD environments is to use the `TELERIK_LICENSE` environment variable.

The recommended way to provide your license key to the `Telerik.Licensing` NuGet package in CI/CD environment is to use an environment variable. Each CI/CD platform has a different process for setting environment variables. This article lists only some of the most popular examples.
Use `TELERIK_LICENSE_PATH` or [only a license file](slug:installation-license-key#manual-installation) on Windows and Windows Server machines, which are managed directly through the operating system's user interface. Do not use the `TELERIK_LICENSE` environment variable in this case, due to the large variable value length.

### Azure Pipelines
> Treat the license key and the license file as secrets. Always store and retrieve them in a secure manner, according to the build platform's best practices.

1. Create a new [secret variable](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#secret-variables). Follow the respective producedure for your **YAML**, **Classic**, or **CLI** pipeline setup. Also check the separate article [Set Secret Variables](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-secret-variables).
## Azure Pipelines

Azure Pipelines provides built-in tools to store and use secret environment variables and secure files. The recommended option with **Classic** pipelines is to [download the Telerik license file as a secure file](#use-telerik_license_path).

### Use TELERIK_LICENSE

1. Create a new [secret variable](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#secret-variables). Also check the separate article [Set Secret Variables](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-secret-variables).
1. Paste the contents of the license key file as a value of the secret variable.
1. Map the secret variable to a new environment variable named `TELERIK_LICENSE`.
1. Use the `TELERIK_LICENSE` environment variable in the tasks, steps, or scripts that build and publish the Blazor app. **Classic** pipelines may need to [set an output variable to share and consume the license key in multiple steps](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-variables-scripts?view=azure-devops&tabs=bash#set-an-output-variable-for-use-in-future-jobs).
Expand All @@ -43,36 +51,73 @@ steps:
# ...
env:
TELERIK_LICENSE: $(Secret_Telerik_License_Key)

- task: DotNetCoreCLI@2
inputs:
command: 'publish'
# ...
env:
TELERIK_LICENSE: $(Secret_Telerik_License_Key)
````

> Another option is to use a Telerik license file as a [secure file in the pipeline](https://learn.microsoft.com/en-us/azure/devops/pipelines/library/secure-files). Implement a [script that copies the license file](https://learn.microsoft.com/en-us/azure/devops/pipelines/library/secure-files?view=azure-devops#consume-a-secure-file-in-a-pipeline) to the application's root folder, so that it's available to all projects that need it.
### Use TELERIK_LICENSE_PATH

1. [Add a secure file](https://learn.microsoft.com/en-us/azure/devops/pipelines/library/secure-files) and grant any necessary permissions to use it in the pipeline.
1. [Download the secure file](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/download-secure-file-v1?view=azure-pipelines) during pipeline run. The secure file path is available through the [`secureFilePath` output](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/download-secure-file-v1?view=azure-pipelines#output-variables).
1. Set the `TELERIK_LICENSE_PATH` environment variable in all tasks, steps, or scripts that build and publish the Blazor app.

>caption Using a TELERIK_LICENSE_PATH environment variable in Azure Pipeline YAML

````YAML.skip-repl
steps:

- task: DownloadSecureFile@1
name: telerikLicense
displayName: 'Download telerik-license.txt'
inputs:
secureFile: 'telerik-license.txt'

- task: DotNetCoreCLI@2
inputs:
command: 'build'
# ...
env:
TELERIK_LICENSE_PATH: $(telerikLicense.secureFilePath)

- task: DotNetCoreCLI@2
displayName: 'Publish'
inputs:
command: 'publish'
# ...
env:
TELERIK_LICENSE_PATH: $(telerikLicense.secureFilePath)
````

### GitHub Actions
## GitHub Actions

1. Create a new [Repository Secret](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) or an [Organization Secret](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-an-organization).
1. Paste the contents of the license key file as a value of the GitHub secret.
1. Assign the secret to an environment variable named `TELERIK_LICENSE`.
1. Use the `TELERIK_LICENSE` environment variable in the steps, which build and publish the Blazor app:
````YAML.skip-repl
env:
TELERIK_LICENSE: ${{ "{{ secrets.Telerik_License_Key }}" }}
````
The resulting workflow steps may look similar to:
````YAML.skip-repl
- name: Build Step
run: dotnet build -c Release
env:
TELERIK_NUGET_KEY: ${{ "{{ secrets.Telerik_NuGet_Key }}" }}
TELERIK_LICENSE: ${{ "{{ secrets.Telerik_License_Key }}" }}

- name: Publish Step
run: dotnet publish -c Release
env:
TELERIK_LICENSE: ${{ "{{ secrets.Telerik_License_Key }}" }}
````
Also see [Using NuGet Keys](slug:deployment-nuget#using-nuget-keys) in the article [Restoring NuGet Packages in Your CI Workflow](slug:deployment-nuget). It shows how to use the `TELERIK_NUGET_KEY` environment variable in your CI build environment.
1. Use the `TELERIK_LICENSE` environment variable in the steps, which build and publish the Blazor app.

### Docker
>caption Using a TELERIK_LICENSE environment variable in GitHub Actions

````YAML.skip-repl
- name: Build Step
run: dotnet build -c Release
env:
TELERIK_NUGET_KEY: ${{ "{{ secrets.Telerik_NuGet_Key }}" }}
TELERIK_LICENSE: ${{ "{{ secrets.Telerik_License_Key }}" }}

- name: Publish Step
run: dotnet publish -c Release
env:
TELERIK_LICENSE: ${{ "{{ secrets.Telerik_License_Key }}" }}
````

Also see [Using NuGet Keys](slug:deployment-nuget#using-nuget-keys) in the article [Restoring NuGet Packages in Your CI Workflow](slug:deployment-nuget). It shows how to use the `TELERIK_NUGET_KEY` environment variable in your CI build environment.

## Docker

1. [Create a Docker build secret](https://docs.docker.com/build/building/secrets/#using-build-secrets) that holds the Telerik license key file.
````SH.skip-repl
Expand All @@ -84,10 +129,6 @@ steps:
dotnet publish BlazorProjectName.csproj -c Release -o /app/publish /p:UseAppHost=false
````

## Using License File

Use a license file on Windows and Windows Server machines, which are managed directly through the operating system's user interface. Do not use an environment variable in these cases.

## Next Steps

* [Restore Telerik NuGet Packages in CI/CD Workflows](slug:deployment-nuget)
Expand Down
Loading