![]() |
VOOZH | about |
Continuous Integration and Continuous Development(CI/CD) is a new methodology, which is gaining huge space in the software industry and got popularity in less time due to its features. However, there are many companies that already have started the software development process using this methodology and others are on this way. There are many advantages of CI/CD, which attracted developers and the software industry towards it and some are below:
There are no defined stages of CI/CD. However, CI/CD is a very flexible methodology and developers can set these stages according to their choice. There are below some standard choice of CI/CD stages and these are all in the pipeline if previous stages fail it will not go to the next stage.
👁 ImageThere are many software tools available which are providing an implementation of CI/CD, and some are below and these can be used by developers or companies' choice and each one has its own characteristics:
There can be any software tool to implement CI/CD as mentioned above. However, GitLab providing CI/CD implementation in a flexible way, and without much knowledge or other additional software, anyone who has some basic knowledge about software development, can easily setup CI/CD configuration with GitLab. Below are some requirements:
Follow the below steps, download GitLab Runner on Windows, and go through commands to verify and register it.
1. Download the GitLab runner from https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-windows-386.exe 2. Create a folder in your local directory (for ex. C:\GitLab-Runner) and rename the downloaded file to gitlab-runner.exe, store it in this folder.
3. Type below command, to verify and register it.
There are many commands of GitLab Runner if already installed in the system, For example, start GitLab Runner, Stop GitLab Runner, Register, etc.
| Command | Description |
| gitlab-runner.exe register | Register the project with CI/CD |
| gitlab-runner.exe start | Start the runner |
| gitlab-runner.exe stop | Stop the runner |
| gitlab-runner.exe status | To know the status of gitlab-runner |
| gitlab-runner unregister --name test-runner | Unregister Runner of a project and replace test-runner with your runner name and this name can be found inside the config.toml file (where your gitlab.exe) available. |
| gitlab-runner unregister --url http://gitlab.example.com/ --token t0k3n | Remove Runner by URL and token |
| gitlab-runner unregister --all-runners | Unregister All Runners |
| gitlab-runner restart | This command stops and then starts the GitLab Runner service |
| gitlab-runner uninstall | This command stops and uninstalls the GitLab Runner from being run as a service |
| gitlab-runner exec | To see a list of available executors, run |
| gitlab-runner --help | Check a recent list of commands by executing |
| gitlab-runner run --help | can see the name of the environment variable |
| gitlab-runner --debug | To run a command in debug mode |
| gitlab-runner exec shell | To see a list of all available options for the shell executor, run |
Follow the below steps to download GitLab Runner on Linux Environment and go through the below commands to verify and register a project.
| Command | Description |
| sudo gitlab-runner register | Register the project with CI/CD |
| sudo gitlab-runner start | Start the runner |
| sudo gitlab-runner stop | Stop the runner |
| sudo gitlab-runner status | To know the status of gitlab-runner |
| sudo gitlab-runner unregister --name test-runner | Unregister Runner of a project and replace test-runner with your runner name and this name can be found inside the config.toml file (where your gitlab.exe) available |
| sudo gitlab-runner unregister --url http://gitlab.example.com/ --token | Remove Runner by Url and token |
| sudo gitlab-runner unregister --all-runners | Unregister All Runners |
| sudo gitlab-runner restart | This command stops and then starts the GitLab Runner service |
| sudo gitlab-runner uninstall | This command stops and uninstalls the GitLab Runner from being run as a service |
| sudo gitlab-runner exec | To see a list of available executors, run |
| sudo gitlab-runner --help | Check a recent list of commands by executing |
| sudo gitlab-runner run --help | Can see the name of the environment variable |
| sudo gitlab-runner --debug | To run a command in debug mode |
| sudo gitlab-runner exec shell | To see a list of all available options for the shell executor, run |
Follow the below steps to configure CI/CD with Windows Environment projects:
Follow the below steps to configure CI/CD with Linux Project.
This is an important step to include yml file to your source code directory, if you do not include it CI/CD will not work. This file includes a configuration that how this project will run.
For Example, .Net project Yml File format
variables:
NUGET_PATH: 'C:\Tools\Nuget\nuget.exe'
MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe'
XUNIT_PATH: packages\xunit.runner.console.2.3.1\tools\net452
UNITTEST_FOLDER: '.\tests\CiCdExample.Tests\bin\Release\'
stages:
- build
- test
- deploy
build_job:
stage: build
only:
- branches
script:
- '& "$env:NUGET_PATH" restore'
- '& "$env:MSBUILD_PATH" /p:Configuration=Release /clp:ErrorsOnly'
- '& "$env:MSBUILD_PATH" src\CiCdExample\CiCdExample.csproj /p:DeployOnBuild=true /p:Configuration=Release /P:PublishProfile=FolderProfile.pubxml'
artifacts:
expire_in: 20 days
paths:
- '.\src\CiCdExample\bin\Release\Publish\'
- '$env:UNITTEST_FOLDER'
- '.\$env:XUNIT_PATH\*.*'
test_job:
stage: test
only:
- branches
script:
- '& "$env:XUNIT_PATH\xunit.console.exe" "$env:UNITTEST_FOLDER\CiCdExample.Tests.dll"'
dependencies:
- build_job
deploy_job:
stage: deploy
only:
- branches
script:
- 'xcopy /y /s ".\src\CiCdExample\bin\Release\Publish\*.*" "C:\Tools\inetpub\wwwroot\ci-cd-example"'
dependencies:
- build_job
- test_job
C/C++ Yml Project format
image: gcc
stages:
- build
- test
build_job:
stage: build
only:
- master
script:
- cd sourcecode
- export CXX=/usr/bin/g++
- export CC=/usr/bin/gcc
- chmod -R 777 *
- ./compileproject.sh
artifacts:
expire_in: 365 days
paths:
- sourcecode/testdata_1.0
test_job:
stage: test
only:
- master
script:
- pwd
- ls -lrt sourcecode/testdata_1.0
- cd testDir
- chmod -R 777 *
- ./runtests.sh
dependencies:
- build_job