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. You can modify these snippets as necessary to fit your GitLab CI/CD deployment pipeline. 

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 runners also require the python3-venv package

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). 

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_RELEASE_VERSION: An environment variable or build parameter to use as a version within Solsta (optional)
  • 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. If the specified product, environment and repository do not exist, they will be automatically created. 
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: llamacraft
  SOLSTA_ENV: dev-nightly
  SOLSTA_REPOSITORY: game-client
  SOLSTA_RELEASE_VERSION: 7.0.10
  SOLSTA_CONSOLE_VERSION: 6.1.2.51
  SOLSTA_SCRIPTS_VERSION: 3.7.24
  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
    - echo "SSN Deploy Script version 1"
    - if (Test-Path -Path deploy) { rm -r -fo deploy }
    # Download the latest deploy scripts
    - mkdir deploy
    - cd deploy
    - wget -UseBasicParsing -O deploy-scripts-$Env:SOLSTA_SCRIPTS_VERSION.zip https://releases.snxd.com/deploy-scripts-$Env:SOLSTA_SCRIPTS_VERSION.zip
    - Expand-Archive deploy-scripts-$Env:SOLSTA_SCRIPTS_VERSION.zip -DestinationPath .
    # 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"",""scope"":""d4tv1""}}"  | out-file -encoding ASCII client_credentials.json
    # 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 --component=console --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
    - $SOLSTA_EXTRA_ARGS = ""
    - if ( "$Env:SOLSTA_RELEASE_VERSION" -ne "" ) { $SOLSTA_EXTRA_ARGS+="--version=$Env:SOLSTA_RELEASE_VERSION " }
    - python release_deploy.py --autocreate --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 $SOLSTA_EXTRA_ARGS
				
			

Linux/macOS Deploy Example

				
					variables:
  SOLSTA_PRODUCT: llamacraft
  SOLSTA_ENV: dev-nightly
  SOLSTA_RELEASE_VERSION: 7.0.11
  SOLSTA_REPOSITORY: game-client
  SOLSTA_CONSOLE_VERSION: 6.1.2.51
  SOLSTA_CONSOLE_DIR: /home/gitlab-runner/console/
  SOLSTA_SCRIPTS_VERSION: 3.7.24
  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
    - echo "SSN Deploy Script version 1"
    - if [ -d "deploy" ]; then rm -Rf deploy; fi
    # Download the latest deploy scripts
    - mkdir deploy
    - cd deploy
    - wget https://releases.snxd.com/deploy-scripts-$SOLSTA_SCRIPTS_VERSION.zip
    - unzip deploy-scripts-$SOLSTA_SCRIPTS_VERSION.zip
    # Generate console credential file from env vars
    - echo "{\"consoleCredentials\":{\"audience\":\"https://axis.snxd.com/\",\"clientId\":\"$SOLSTA_CLIENT_ID\",\"clientSecret\":\"$SOLSTA_CLIENT_SECRET\",\"grant\":\"clientCredentials\",\"scope\":\"d4tv1\"}}"  > client_credentials.json
    # 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 --component=console --console_credentials=client_credentials.json ; fi
    # Run the script that creates a new release and deploys it
    - SOLSTA_EXTRA_ARGS=""
    - if [ ! "$SOLSTA_RELEASE_VERSION" = "" ]; then SOLSTA_EXTRA_ARGS+="--version=$SOLSTA_RELEASE_VERSION " ; fi ;
    - python release_deploy.py --autocreate --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 $SOLSTA_EXTRA_ARGS
				
			

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: llamacraft
  SOLSTA_SOURCE_ENV: dev-nightly
  SOLSTA_SOURCE_REPOSITORY: game-client
  SOLSTA_CONSOLE_VERSION: 6.1.2.51
  SOLSTA_SCRIPTS_VERSION: 3.7.24
  SOLSTA_CONSOLE_DIR: c:/temp/direct/
  SOLSTA_PROMOTE_TARGET_PRODUCT: llamacraft
  SOLSTA_PROMOTE_TARGET_ENV: qa-internal
  SOLSTA_PROMOTE_TARGET_REPOSITORY: game-client
image: maven:3.3.9-jdk-8
stages: [promote]
promote:jdk8:
  stage: promote
  script:
    # Remove the old deploy script directory
    - echo "SSN Promote Script version 1"
    - if (Test-Path -Path deploy) { rm -r -fo deploy }
    # Download the latest deploy scripts
    - mkdir deploy
    - cd deploy
    - wget -UseBasicParsing -O deploy-scripts-$Env:SOLSTA_SCRIPTS_VERSION.zip https://releases.snxd.com/deploy-scripts-$Env:SOLSTA_SCRIPTS_VERSION.zip
    - Expand-Archive deploy-scripts-$Env:SOLSTA_SCRIPTS_VERSION.zip -DestinationPath .
    # 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"",""scope"":""d4tv1""}}"  | out-file -encoding ASCII client_credentials.json
    # 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 --component=console --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: llamacraft
  SOLSTA_SOURCE_ENV: dev-nightly
  SOLSTA_SOURCE_REPOSITORY: game-client
  SOLSTA_CONSOLE_VERSION: 6.1.2.51
  SOLSTA_CONSOLE_DIR: /home/gitlab-runner/console/
  SOLSTA_SCRIPTS_VERSION: 3.7.24
  SOLSTA_PROMOTE_TARGET_PRODUCT: llamacraft
  SOLSTA_PROMOTE_TARGET_ENV: qa-internal
  SOLSTA_PROMOTE_TARGET_REPOSITORY: game-client
image: maven:3.3.9-jdk-8
stages: [promote]
promote:jdk8:
  stage: promote
  script:
    # Remove the old deploy script directory
    - echo "SSN Promote Script version 1"
    - if [ -d "deploy" ]; then rm -Rf deploy; fi
    # Download the latest deploy scripts
    - mkdir deploy
    - cd deploy
    - wget https://releases.snxd.com/deploy-scripts-$SOLSTA_SCRIPTS_VERSION.zip
    - unzip deploy-scripts-$SOLSTA_SCRIPTS_VERSION.zip
    # Generate console credential file from env vars
    - echo "{\"consoleCredentials\":{\"audience\":\"https://axis.snxd.com/\",\"clientId\":\"$SOLSTA_CLIENT_ID\",\"clientSecret\":\"$SOLSTA_CLIENT_SECRET\",\"grant\":\"clientCredentials\",\"scope\":\"d4tv1\"}}"  > client_credentials.json
    # 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 --component=console --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