what is GitLab?
Gitlab is basically a web-based DEVOPS lifecycle tool
In layman Terms it is an advanced version of Github
Features
CI/CD pipeline features
monitoring and security tool
Collaboration of code and project management
BUILDING -> TESTING -> DEPLOYEMENT
GITLAB SETUP
-> open gitlab.com
-> login using google or github
-> create a new file in the format -> .gitlab-ci.yml
-> and write a sample code as below
build:
script:
- echo "first step"
- echo "Second step"
-Now commit the changes made as you do in github
-And see the magic the pipeline will process and we can similarly create multiple jobs and see each process will only take place after the previous one has completed
-So its very easy to automatically automate the process of building testing and deployement so there will be no downtime in any website when the changes are made and the users will not be affected
We can also create multiple jobs but we see that all the jobs will run at the same time parallely
The below code depicts that process
#build step
build-job:
script:
- echo "Building Phase"
test-job:
script:
- echo "testing Phase"
deploy-job:
script:
- echo "deploying Phase"
Now if we want to make them run one after other use the below code
#build step stages: - build - test - deploy build-job: stage: build script: - echo "Building Phase" test-job: stage: test script: - echo "testing Phase" deploy-job: stage: deploy script: - echo "deploying Phase"
-Now see it happens one after other
Running bash scripts using GitLab
#!/bin/bash
echo "hello world"
echo "end of script"
Now make changes in gitlab-ci.yml file
bash_execute:
script:
- bash ./basic.sh
Thats it so simple and easy
Email Notifications :
We can notified in mail if there is any pipeline error during our commit to make us be aware of the recent changes and updates or errors
And notifies us if the error in the pipeline is fixed or not
Croning jobs using gitlab
We can even use cron jobs to schedule our task
At what Time, month, hour or at what minute that task needs to be done
very helpful because 24/7 we wont be sitting at the system monitoring use we use cron jobs to automate the process
What is CI/CD PIPELINES?
CI/CD โ continuous development and continuous integration
Imagine you're working with a team on a web application project. Every time a team member pushes code changes to Git, GitLab's CI/CD pipeline triggers:
The build step compiles the code.
The test step runs unit tests, integration tests, and possibly code quality checks.
If everything passes, the deploy step deploys the code to a staging environment. In some cases, it may even automatically deploy to production.