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_IDValue: The ID of your seenode application.
- Key: SEENODE_API_TOKENValue: Your seenode API token.
 
- Key: 
 
- 
Configure the GitLab CI/CD Pipeline Create a .gitlab-ci.ymlfile 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 deploystage that runs a script to trigger a new deployment on seenode. It uses a minimalcurlimage to execute the request. The job is configured to run only on pushes to themainbranch.
- 
Commit and Push Commit the .gitlab-ci.ymlfile 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 rulessection of your.gitlab-ci.ymlfile.
- Authentication Error: Double-check that your SEENODE_API_TOKENandSEENODE_APPLICATION_IDvariables 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 curlpre-installed. If you are using a different Docker image, ensurecurlis available.
- Invalid Request: Verify the API endpoint in the curlcommand. 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.
 
 