Solsta GitLab CI Integration

The GitLab CI/CD YAML examples below outline how to use the Solsta deployment tools, scripts and API service to deploy and promote releases within the Solsta ecosystem. Deploying consists of converting and uploading raw files (assets) to a bucket in order to make releases available for download by Solsta desktop clients. These sample YAML snippets are meant to demonstrate a basic deployment and promotion using the Solsta deployment tools. Before using any of these snippets in your GitLab CI/CD pipeline, you can modify them as necessary to fit your deployment workflow. 

Runner/Executor Requirements

In order to perform Solsta deployments, Runners on your GitLab CI/CD instance will need to have the following components installed:

  • .NET 6.0
  • Python 3.9+

Linux users will need to remember to install the python3-venv package as well.

Authentication

The Solid State Networks deployment tools require authentication using M2M credentials that were provided when your company signed up for Solsta. Contact your company’s primary contact with Solid State Networks or open a support ticket for assistance.
 
The YAML examples below require the credentials to be set as two environment variables before executing a pipeline.
  • SOLSTA_CLIENT_ID
  • SOLSTA_CLIENT_SECRET

These variables can be set in the Settings > CI/CD section of your GitLab project where they can be protected and masked (see image below for an example). Alternatively, they can be specified during the Run pipeline workflow.

Setup

The Solsta deployment examples require the creation of Products, Environments and Repositories within the Solsta deployment database. Please see the articles below for how to create those objects using the Solsta Desktop Application.

Once these objects have been created, you can use the examples from this page in your GitLab CI/CD pipeline. 

YAML Deploy Examples

In the deployment examples below, custom CI/CD variables are defined for the following:
  • SOLSTA_PRODUCT: Target product for deployment
  • SOLSTA_ENV: Target environment within containing product
  • SOLSTA_REPOSITORY:  Target repository within containing environment
  • SOLSTA_CONSOLE_VERSION: Version of the Solsta deployment tools. Do not change this unless instructed to do so by Solsta support staff.
  • SOLSTA_CONSOLE_DIR: Path on Runner machine(s) to save the Solsta deployment tools
  • SOLSTA_DEPLOY_SOURCE_PATH: Relative path to folder within build checkout directory. The contents of the folder will be deployed.
As part of the deployment process, the script downloads the latest Solsta deployment tools (if they are not already available) into a local directory on the runner specified by SOLSTA_CONSOLE_DIR. Next, it executes the release_deploy script to deploy (upload) your build assets to your Solsta bucket.
Replace the echo lines
To use this basic Solsta deployment sample, replace the echo lines in the script section of the YAML below with the scripts and processes that build or compile your release. As mentioned above, you can use this YAML within your pipeline to best suite your needs. The Solsta deployment tools only need to be pointed to the path containing your cooked, ready-to-deploy data (or build artifacts). This can be done by editing the value of the SOLSTA_DEPLOY_SOURCE_PATH variable. Note that the runner executing the pipeline needs to have access to the files in that path.
Example:
SOLSTA_DEPLOY_SOURCE_PATH: s3://mybucket/mybuilds/v38.1.2/

Windows Powershell Deployment Example

				
					variables:
  SOLSTA_PRODUCT: plugins
  SOLSTA_ENV: gitlab
  SOLSTA_REPOSITORY: gameclient
  SOLSTA_CONSOLE_VERSION: 6.1.1.12
  SOLSTA_CONSOLE_DIR: c:/temp/direct/
  SOLSTA_DEPLOY_SOURCE_PATH: "../bin/"
image: maven:3.3.9-jdk-8
stages: [build]
build:jdk8:
  stage: build
  script:
    - echo "Your Build Happens Here"
    - echo "Your Build Artifacts Are now in bin/"
    # Remove the old deploy script directory
    - if (Test-Path -Path deploy) { rm -r -fo deploy }
    # Download the latest deploy scripts
    - git clone --branch 3.7 https://gitlab.com/snxd/deploy.git
    # Generate console credential file from env vars
    - echo "{""consoleCredentials"":{""audience"":""https://axis.snxd.com/"",""clientId"":""$Env:SOLSTA_CLIENT_ID"",""clientSecret"":""$Env:SOLSTA_CLIENT_SECRET"",""grant"":""clientCredentials""}}"  | out-file -encoding ASCII deploy/client_credentials.json
    - cd deploy
    # Create the python venv in the deploy directory
    - if (!(Test-Path -Path venv)) { python -m venv venv }
    # Activate the new python environment
    - venv\Scripts\activate
    # Install any missing deploy script dependencies
    - pip install -r requirements.txt
    # Download the latest SSN Console Tools if necessary
    - if (!(Test-Path -Path $Env:SOLSTA_CONSOLE_DIR$Env:SOLSTA_CONSOLE_VERSION/console)) { python direct_get.py --overwrite --version=$Env:SOLSTA_CONSOLE_VERSION --target_directory=$Env:SOLSTA_CONSOLE_DIR$Env:SOLSTA_CONSOLE_VERSION --console_credentials=client_credentials.json }
    # Run the script that creates a new release and deploys it
    - python release_deploy.py --debug --console_credentials=client_credentials.json --console_directory=$Env:SOLSTA_CONSOLE_DIR$Env:SOLSTA_CONSOLE_VERSION/console --product_name=$Env:SOLSTA_PRODUCT --env_name=$Env:SOLSTA_ENV --repository_name=$Env:SOLSTA_REPOSITORY --source=$Env:SOLSTA_DEPLOY_SOURCE_PATH
				
			

Linux/macOS Deploy Example

				
					variables:
  SOLSTA_PRODUCT: plugins
  SOLSTA_ENV: gitlab
  SOLSTA_REPOSITORY: gameclient
  SOLSTA_CONSOLE_VERSION: 6.1.1.12
  SOLSTA_CONSOLE_DIR: "/home/gitlab-runner/direct/"
  SOLSTA_DEPLOY_SOURCE_PATH: "../bin/"
image: maven:3.3.9-jdk-8
stages: [build]
build:jdk8:
  stage: build
  script:
    - echo "Your Build Happens Here" 
    - echo "Your Build Artifacts Are now in bin/" 
    # Remove the old deploy script directory
    - if [ -d "deploy" ]; then rm -Rf deploy; fi
    # Download the latest deploy scripts
    - git clone --branch 3.7 https://gitlab.com/snxd/deploy.git
    # Generate console credential file from env vars
    - echo "{\"consoleCredentials\":{\"audience\":\"https://axis.snxd.com/\",\"clientId\":\"$SOLSTA_CLIENT_ID\",\"clientSecret\":\"$SOLSTA_CLIENT_SECRET\",\"grant\":\"clientCredentials\"}}"  > deploy/client_credentials.json
    - cd deploy
    # Create the python venv in the deploy directory
    - if [ ! -f "venv" ]; then python3 -m venv venv ; fi
    # Activate the new python environment
    - source venv/bin/activate
    # Install any missing deploy script dependencies
    - pip install -r requirements.txt
    # Download the latest SSN Console Tools if necessary
    - if [ ! -d "$SOLSTA_CONSOLE_DIR$SOLSTA_CONSOLE_VERSION/console" ]; then python direct_get.py --overwrite --version=$SOLSTA_CONSOLE_VERSION --target_directory=$SOLSTA_CONSOLE_DIR$SOLSTA_CONSOLE_VERSION --console_credentials=client_credentials.json ; fi
    # Run the script that creates a new release and deploys it
    - python release_deploy.py --debug --console_credentials=client_credentials.json --console_directory=$SOLSTA_CONSOLE_DIR$SOLSTA_CONSOLE_VERSION/console --product_name=$SOLSTA_PRODUCT --env_name=$SOLSTA_ENV --repository_name=$SOLSTA_REPOSITORY --source=$SOLSTA_DEPLOY_SOURCE_PATH
				
			

YAML Promote Examples

In the promote examples below, custom CI/CD variables are defined for the following:
  • SOLSTA_SOURCE_PRODUCT: Source product for promotion
  • SOLSTA_SOURCE_ENV: Source environment within containing product
  • SOLSTA_SOURCE_REPOSITORY: Source repository within containing environment
  • SOLSTA_CONSOLE_VERSION: Version of the Solsta deployment tools. Do not change this unless instructed to do so by Solsta support staff.
  • SOLSTA_CONSOLE_DIR: Path on Runner machine(s) to save the Solsta deployment tools.
  • SOLSTA_PROMOTE_TARGET_PRODUCT: Target product for promotion
  • SOLSTA_PROMOTE_TARGET_ENV: Target environment within containing product
  • SOLSTA_PROMOTE_TARGET_REPOSITORY: Target repository within containing environment
As part of the promotion process, the script will check for and download the Solsta deployment tools if necessary, then execute the manifest_promote script to promote a release from a source Product, Environment and Repository to a target Product, Environment and Repository. If the target environment has an update path count value greater than zero, the runner will automatically create delta update paths within the target Environment and Repository as part of the promotion step.

Windows Powershell Promote Example

				
					variables:
  SOLSTA_SOURCE_PRODUCT: plugins
  SOLSTA_SOURCE_ENV: gitlab-dev
  SOLSTA_SOURCE_REPOSITORY: gameclient
  SOLSTA_CONSOLE_VERSION: 6.1.1.12
  SOLSTA_CONSOLE_DIR: c:/temp/direct/
  SOLSTA_PROMOTE_TARGET_PRODUCT: plugins
  SOLSTA_PROMOTE_TARGET_ENV: gitlab-qa
  SOLSTA_PROMOTE_TARGET_REPOSITORY: gameclient
image: maven:3.3.9-jdk-8
stages: [promote]
promote:jdk8:
  stage: promote
  script:
    # Remove the old deploy script directory
    - if (Test-Path -Path deploy) { rm -r -fo deploy }
    # Download the latest deploy scripts
    - git clone --branch 3.7 https://gitlab.com/snxd/deploy.git
    # Generate console credential file from env vars
    - echo "{""consoleCredentials"":{""audience"":""https://axis.snxd.com/"",""clientId"":""$Env:SOLSTA_CLIENT_ID"",""clientSecret"":""$Env:SOLSTA_CLIENT_SECRET"",""grant"":""clientCredentials""}}"  | out-file -encoding ASCII deploy/client_credentials.json
    - cd deploy
    # Create the python venv in the deploy directory
    - if (!(Test-Path -Path venv)) { python -m venv venv }
    # Activate the new python environment
    - venv\Scripts\activate
    # Install any missing deploy script dependencies
    - pip install -r requirements.txt
    # Download the latest SSN Console Tools if necessary
    - if (!(Test-Path -Path $Env:SOLSTA_CONSOLE_DIR$Env:SOLSTA_CONSOLE_VERSION/console)) { python direct_get.py --overwrite --version=$Env:SOLSTA_CONSOLE_VERSION --target_directory=$Env:SOLSTA_CONSOLE_DIR$Env:SOLSTA_CONSOLE_VERSION --console_credentials=client_credentials.json }
    # Run the script that promotes a release to a new repository
    - python manifest_promote.py --debug --console_credentials=client_credentials.json --console_directory=$Env:SOLSTA_CONSOLE_DIR$Env:SOLSTA_CONSOLE_VERSION/console --source_product_name=$Env:SOLSTA_SOURCE_PRODUCT --source_env_name=$Env:SOLSTA_SOURCE_ENV --source_repository_name=$Env:SOLSTA_SOURCE_REPOSITORY --process_default=API --product_name=$Env:SOLSTA_PROMOTE_TARGET_PRODUCT --env_name=$Env:SOLSTA_PROMOTE_TARGET_ENV --repository_name=$Env:SOLSTA_PROMOTE_TARGET_REPOSITORY
				
			

Linux/macOS Promote Example

				
					variables:
  SOLSTA_SOURCE_PRODUCT: plugins
  SOLSTA_SOURCE_ENV: gitlab-dev
  SOLSTA_SOURCE_REPOSITORY: gameclient
  SOLSTA_CONSOLE_VERSION: 6.1.1.12
  SOLSTA_CONSOLE_DIR: "/Users/macos/direct/"
  SOLSTA_PROMOTE_TARGET_PRODUCT: plugins
  SOLSTA_PROMOTE_TARGET_ENV: gitlab-qa
  SOLSTA_PROMOTE_TARGET_REPOSITORY: gameclient
image: maven:3.3.9-jdk-8
stages: [promote]
promote:jdk8:
  stage: promote
  script:
    # Remove the old deploy script directory
    - if [ -d "deploy" ]; then rm -Rf deploy; fi
    # Download the latest deploy scripts
    - git clone --branch 3.7 https://gitlab.com/snxd/deploy.git
    # Generate console credential file from env vars
    - echo "{\"consoleCredentials\":{\"audience\":\"https://axis.snxd.com/\",\"clientId\":\"$SOLSTA_CLIENT_ID\",\"clientSecret\":\"$SOLSTA_CLIENT_SECRET\",\"grant\":\"clientCredentials\"}}"  > deploy/client_credentials.json
    - cd deploy
    # Create the python venv in the deploy directory
    - if [ ! -f "venv" ]; then python3 -m venv venv ; fi
    # Activate the new python environment
    - source venv/bin/activate
    # Install any missing deploy script dependencies
    - pip install -r requirements.txt
    # Download the latest SSN Console Tools if necessary
    - if [ ! -d "$SOLSTA_CONSOLE_DIR$SOLSTA_CONSOLE_VERSION/console" ]; then python direct_get.py --overwrite --version=$SOLSTA_CONSOLE_VERSION --target_directory=$SOLSTA_CONSOLE_DIR$SOLSTA_CONSOLE_VERSION --console_credentials=client_credentials.json ; fi
    # Run the script that promotes a release to a new repository
    - python manifest_promote.py --debug --console_credentials=client_credentials.json --console_directory=$SOLSTA_CONSOLE_DIR$SOLSTA_CONSOLE_VERSION/console --source_product_name=$SOLSTA_SOURCE_PRODUCT --source_env_name=$SOLSTA_SOURCE_ENV --source_repository_name=$SOLSTA_SOURCE_REPOSITORY --process_default=API --product_name=$SOLSTA_PROMOTE_TARGET_PRODUCT --env_name=$SOLSTA_PROMOTE_TARGET_ENV --repository_name=$SOLSTA_PROMOTE_TARGET_REPOSITORY