Gitlab CI/CD deployment issue environment wise - gitlab

I have setup the Gitlab CI/CD for Sandbox environment. Now, I want to setup the same CI/CD for UAT environment. So I have created a different branch for UAT and in the gitlab-ci.yml file made the changes like Runner tag, variables and all.
Our developer merge the code from Sandbox environment to UAT whenever they want to do the deployment in UAT but the issues comes like while merging it through merge conflict error as the Runner tag, variables, env file names are different.
How to overcome this issue?

Related

Gitlab CI - Specifying Runner Per Job

We are currently facing a conundrum with our multi-tenant project which contains various configuration files for each of our tenants and their associated environment. Our CI/CD Pipeline is split into two parts
An Upstream pipeline which analyses the new commit to master to
determine which tenants/environments have been changed. This triggers
the downstream pipeline with the correct environment variables via
the API
A downstream pipeline which executes scripts to deploy
changes to the tenants' environment based on the environment variables
passed through. This works well, however we have a Gitlab Runner per
environment to access the customers environment. We use this to avoid
hard-coding multiple credentials within our scripts or CI environment
variables.
Is there a way we can trigger this downstream pipeline with the specific Gitlab Runner? Our Gitlab Runners are tagged per environment so that we can use the passed environment variables to detect which runner it should be ran on.
I’ve had a look around the Gitlab CI, specific runners and shared runners (which ours are currently) but doesn’t seem to be supported.
tags: supports variable expansion. So, it is possible to pass variables in the API call when creating your downstream pipelines in order to control which runners are used.

What is the best way to create Azure devops automated release pipeline with Git flow

I have an application with .NET Core web API and Angular client application which is hosted in Azure as app services. Trying to introduce full DevOps practice to this up until production.
I'm trying to create a release pipeline in Azure DevOps while keeping git-flow as my branching strategy. currently,
I have 5 different environments which are Dev > QA > UAT > Pre-Prod > PRODUCTION.
I know with a trunk-based approach this is pretty easy to configure with one release pipeline which will go through all the environments as one release until it goes to production. In the current setup, this is automated only up to the UAT environment using Only the Development branch as the release pipeline which works pretty well.
I'm wondering what would be the most suitable way to do it keeping git-flow as my branching strategy. Also, relevant branches should automatically tag with UAT and production releases.
Mainly I have a development branch that contains the latest development activities and feature branches will be merged into development after PR approvals and Master is the production equal branch.
With my current environments setup, releasing this to UAT is quite simple with the Development branch but when proceeding to Production it might cause problems.
To keep the question short considering multiple factors, I was planning to have 3 different pipelines as follows
UAT - One release pipeline from development which goes through Dev > QA > UAT
Prod - Master branch will be configured with this pipeline which goes through Pre-Prod > Prod environments. this will be a separate build pipeline which will trigger soon after development merges with the master branch. this will be the main production pipeline. either this could be a master or separate release branch.
Hotfix - This will be the Production hotfix release pipeline with a separate build pipeline which goes through QA > Pre-Prod > Prod.
Will this approach works or any bettor way of doing this. Since this is the very first time planning release it to production through the pipeline. I would like to hear advice from experts?

Can gitlab require validation from lower environments for deploy?

Gitlab has a notion of environments. I'd like to define a deployment stage for production, but only allow to run it, if the same commit has been deployed successfully in staging. Is this best done in one pipeline with prod jobs after staging or is there some way to define a dependency for environments?
Since you can:
view environments and their associated deployments
query a specific environment
I would make as a first step of my deployment stage for production one that queries the staging environment, get the deployable/commit id associated to that environment (part of the JSON answer), and compare it with the commit being deployed to production.
If that does not match, the pipeline would stop immediately in error.

Gitlab pipeline checkout access

I'm trying pipelines in git lab community edition.
For what I can understand, from gitlab, the code and pipelines live in the same git repository.
In my scenario the pipelines are responsibility of devops team and code from develop team.
How, in git lab, is possible to prevent developers of changing the pipeline?
I understand it's possible to add devops team as maintainer to review pull requests, but this will create a dependency of devops teams in every change.
thanks
GitLab is not really designed for the scenario you describe. The general idea is that developers look after the CI configuration themselves.
You could try using the includes feature to store the bulk of the CI configuration in a separate repository.
In the application repository you would have a .gitlab-ci.yml file that pulls the CI configuration in from another repository using include-project:
include:
- project: 'my-group/my-ciproject'
ref: master
file: '/ci/.gitlab-ci-myappproject.yml'
Then in the my-group/my-ciproject repository you would have a file .gitlab-ci-myappproject.yml that contains the GitLab CI jobs configuration.
build:
script:
- dobuild
Only the DevOps team would have access to the my-group/my-ciproject repository so developers can't edit the CI config (although could mess with the .gitlab-ci.yml` file in the app repository).
Alternatively you could protect the master branch and have all changes approved before merging to master. Then developers would not be able to make changes to the CI without an approval.

CI/CD Pipeline to multiple environments

I am learning CI/CD concepts and trying to set up a pipe line in Azure to deploy my sample api to dev, int,qa and prod environments. I was able to deployment the build successfully to all environments. But what is the correct way of doing CI/CD in the companies? We cannot have build on every check-in to all environments even though we have the unit testing run in the build. The usual flow should be Unit test then deploy to Stage/QA and once QA signs off then we promote the build to PROD right? How does this fit into the CI/CD pipeline? Also we can have multiple builds in Dev, can we select which build to deploy to stg and prod?
The ideal way would be to link each of your check-ins to some bug/task so that it will be linked to appropriate test case .After the check in automated test cases are run simultaneously and test whether the check in is valid. If it is valid you can line it up to deployment which only will be deployed after getting the necessary approvals.It is recommended to run continuous integration pipeline to each check in so that you will have a history of build success and failures which is a big relief when you have to find/track errors.
To the prod environment you have multiple approvals as requirement to deploy and provide all the approvals when the sign off is provided.
For the build to map to stg and prod .yes you can do this .If you are using web app in azure and you have prod and stage slots then you can point the branch to respective slots in the deployment configuration.
Please let me know if you need anything else.
Hope this helps.

Resources