Let's dive into crafting GitLab CI/CD pipelines tailored for SAS Viya. First, you established a GitLab Kubernetes runner. Next, you crafted a bespoke Docker image suited for your SAS Viya ecosystem and uploaded it to a secure, private GitLab container registry. Read this post to understand what a pipeline for SAS Viya looks like, what the different components are and how to put them all together.
In this post series you will learn how to:
Take a look at the following video, in which we demonstrate a GitLab CI/CD pipeline that runs a SAS program in SAS Viya.
Begin by creating a .gitlab-ci.yml file in your repository's root directory:
default:
image: $CI_REGISTRY/$GITLAB_USER_LOGIN/sasgitlabdevops/jass/gitlab-runner-sas:0.07
run-sas-program:
stage: build
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
- echo "CI Registry $CI_REGISTRY"
# test container folders
- ls -la
- ls -la /usr/local/bin
# SAS Viya CLI
- sas-viya plugins list
# TLS Certificate location
- export SSL_CERT_FILE=/usr/local/bin/gelenv_trustedcerts.pem
- echo ${SSL_CERT_FILE}
# SAS Viya CLI profile
- sas-viya --profile dev profile set-endpoint $dev_endpoint
- sas-viya --profile dev profile toggle-color on
- sas-viya --profile dev profile set-output fulljson
- sas-viya --profile dev profile show
- sas-viya --profile dev auth login -user $dev_user -password $dev_passwd
# SAS Viya CLI
- echo Run a SAS program stored in Git
- sas-viya --profile dev batch jobs submit-pgm --pgm-path 1.sas --context default --watch-output --wait-log-list --results-dir ~/
default:
image: $CI_REGISTRY/$GITLAB_USER_LOGIN/sasgitlabdevops/jass/gitlab-runner-sas:0.07
The configuration snippet you've provided is designed to pull a specific Docker image from your GitLab Container Registry for use in your CI/CD pipeline. This Docker image is the one you previously constructed for your SAS Viya environment.
Here's a breakdown of the image directive in your .gitlab-ci.yml file:
The complete image name, including the tag, will be resolved using these variables, ensuring that the correct image is used for the pipeline.
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
To learn more about building the Docker image, refer to the associated post.
The pipeline runs. The Kubernetes runner initiates the execution. The runner creates a temporary Kubernetes executor pod from the pulled Docker image.
The basic bricks in a GitLab CI/CD pipeline are the stage, which contains jobs. The job contains scripts.
run-sas-program:
stage: build
script:
- echo "Hello, $GITLAB_USER_LOGIN!"
Where:
# SAS Viya CLI
- sas-viya plugins list
# TLS Certificate location
- export SSL_CERT_FILE=/usr/local/bin/gelenv_trustedcerts.pem
- echo ${SSL_CERT_FILE}
# SAS Viya CLI profile
- sas-viya --profile dev profile set-endpoint $dev_endpoint
- sas-viya --profile dev profile toggle-color on
- sas-viya --profile dev profile set-output fulljson
- sas-viya --profile dev profile show
- sas-viya --profile dev auth login -user $dev_user -password $dev_passwd
- sas-viya --profile dev batch jobs submit-pgm --pgm-path 1.sas --context default --watch-output --wait-log-list --results-dir ~/
Notice the variables:
These are Project variables, defined under Settings > CI/CD > Variables in GitLab.
From a security perspective you should mask sensitive variables, so that they can’t be printed by accident in a log.
Finally, by using the SAS Viya CLI, you can submit the SAS program to be executed in SAS Viya.
- sas-viya --profile dev batch jobs submit-pgm --pgm-path 1.sas --context default --watch-output --wait-log-list --results-dir ~/
Ultimately, you should see the table successfully loaded in SAS Viya.
In conclusion, this post has walked you through setting up a GitLab CI/CD pipeline designed for SAS Viya, utilizing the Kubernetes runner established in the first step and a custom Docker image crafted in the second step. Looking ahead, we will delve into additional SAS Viya pipelines and various runner options. Thank you for following along!
Many thanks to Jan Kostrubiec @JanKostrubiec , Katarzyna Zuk @KatarzynaŻuk , Lars Arne Skår @larsarne , Neil Griffin
@Neil-Griffin , from whom I learned the most about DevOps with SAS Viya and GitLab.
Thank you for your time reading this post. If you liked the post, give it a thumbs up! Please comment and tell us what you think about having conversations with your data. If you wish to get more information, please write me an email.
Find more articles from SAS Global Enablement and Learning here.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.