Deploying with GitLab CI/CD
This guide explains how to set up a GitLab CI/CD pipeline that automatically triggers a new deployment on Seenode whenever a commit is pushed to a specified branch.
Prerequisites
Section titled “Prerequisites”- A GitLab repository containing your application.
- An existing Seenode application linked to that repository.
- An API token for the Seenode API.
- Permissions to configure CI/CD settings in your GitLab project.
-
Add CI/CD Variables to GitLab
To keep your credentials secure, store them as masked and protected CI/CD variables in your GitLab project.
- In your GitLab project, go to Settings > CI/CD.
- Expand the Variables section.
- Click Add variable and add the following:
- Key:
SEENODE_APPLICATION_ID
Value: The ID of your Seenode application. - Key:
SEENODE_API_TOKEN
Value: Your Seenode API token.
- Key:
-
Configure the GitLab CI/CD Pipeline
Create a
.gitlab-ci.yml
file in the root of your repository to define your deployment pipeline..gitlab-ci.yml stages:- deploydeploy_to_seenode:stage: deployimage: curlimages/curl:latestrules:- if: $CI_COMMIT_BRANCH == "main" # Trigger on pushes to the main branchscript:- |curl -X POST \-H "Authorization: Bearer $SEENODE_API_TOKEN" \-H "Content-Type: application/json" \-d '{"gitCommitSha": "'"$CI_COMMIT_SHA"'"}' \"https://api.seenode.com/v1/applications/$SEENODE_APPLICATION_ID/deployments"This pipeline defines a
deploy
stage that runs a script to trigger a new deployment on Seenode. It uses a minimalcurl
image to execute the request. The job is configured to run only on pushes to themain
branch. -
Commit and Push
Commit the
.gitlab-ci.yml
file to your repository to activate the pipeline.Terminal git add .gitlab-ci.ymlgit commit -m "ci: Add GitLab CI/CD pipeline for Seenode deployment"git push -
Verify the Deployment
Once you’ve pushed the pipeline configuration, you can verify that it’s working correctly.
- In your GitLab project, go to Build > Pipelines. You should see the pipeline running.
- In the Seenode Dashboard, navigate to your application’s Deployments tab. You should see a new deployment in progress.
Troubleshooting
Section titled “Troubleshooting”- Pipeline Not Triggering: Ensure you are pushing to the correct branch specified in the
rules
section of your.gitlab-ci.yml
file. - Authentication Error: Double-check that your
SEENODE_API_TOKEN
andSEENODE_APPLICATION_ID
variables are correct and that they are not configured to be protected if your branch is not a protected branch. - Command Not Found: The example uses an image with
curl
pre-installed. If you are using a different Docker image, ensurecurl
is available. - Invalid Request: Verify the API endpoint in the
curl
command. Ensure the application ID is correct.
Conclusion
Section titled “Conclusion”You have now successfully set up a GitLab CI/CD pipeline to automatically deploy to seenode when changes are pushed to the repository. This automation ensures that your deployments stay consistent and efficient.