Automatisierung
DevOps#
DevOps beschreibt einen Ansatz, wie die Zusammenarbeit zwischen Softwareentwicklung und IT-Betrieb verbessert werden kann.
Mit DevOps sollen die Qualität der Software, die Geschwindigkeit der Entwicklung und der Auslieferung sowie das Miteinander der beteiligten Teams verbessert werden.

DevOps Tools#
DevOps kennt viele Tools. Ein paar bekannte Beispiele werden hier aufgezeigt:

CI/CD#
CI/CD steht für Continuous Integration / Continuous Delivery / Continuous Deployment

Continuous Integration#
Bei der Continuous Integration werden Änderungen am Code bei jedem Commit automatisch gebuildet und getestet auf einem Development Branch (feature, hotfix, develop). Sind alle Unit Tests und Integration Tests erfolgreich wird die Build für ein Review freigegeben.
Continuous Delivery#
Die Continuous Delivery wird manuell nach einem Merge in einen Produktion Branch gestartet. Sie beinhaltet ebenfalls einen automatischen Build und Unit sowie Integration Tests. Treten keine Probleme auf erfolgt ein automatisches Deployment der Produktionsbuild auf die jeweilige Produktionsumgebung.
Continuous Deployment#
Dasselbe wie Continuous Delivery mit dem Unterschied, dass dieser Prozess automatisch gestartet wird, und nicht die Intervention eines Entwicklers voraussetzt wie dies bei Continuous Delivery der Fall ist.
Detaillierte Darstellung von CI/CD#
x
Gitlab Integration#
Für die Umsetzung von CI/CD in Gitlab wird eine Konfigurationsdatei .gitlab-ci.yml im Root-Verzeichnis benötigt.
Die Konfiguration kann in mehrere Stages aufgeteilt werden, welche jeweils ihre eigenen Skripte ausführen:
# This file is a template, and might need editing before it works on your project.# To contribute improvements to CI/CD templates, please follow the Development guide at:# https://docs.gitlab.com/ee/development/cicd/templates.html# This specific template is located at:# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml
# This is a sample GitLab CI/CD configuration file that should run without any modifications.# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts,# it uses echo commands to simulate the pipeline execution.## A pipeline is composed of independent jobs that run scripts, grouped into stages.# Stages run in sequential order, but jobs within stages run in parallel.## For more information, see: https://docs.gitlab.com/ee/ci/yaml/README.html#stages
.node: &node image: node:14 # alternatively use node:latest before_script: - echo "Installing Angular CLI..." - npm install -g @angular/cli - echo "Installing dependencies..." - npm i cache: key: "$CI_COMMIT_REF_NAME" paths: - node_modules/
stages: # List of stages for jobs, and their order of execution - install - build - test - deploy
build_spa: # This job runs in the build stage, which runs first. stage: build <<: *node script: - echo "Compiling the code..." - npm run build - echo "Compile complete."
lint_tests: # This job also runs in the test stage. stage: test # It can run at the same time as unit-test-job (in parallel). <<: *node script: - echo "Linting code..." - npm run lint - echo "No lint issues found."
unit_tests: # This job runs in the test stage. stage: test # It only starts when the job in the build stage completes successfully. <<: *node script: - echo "Running unit tests..." - npm run test - echo "Code coverage is 90%"
e2e_tests: # This job also runs in the test stage. stage: test # It can run at the same time as unit-test-job (in parallel). <<: *node script: - echo "Running end to end tests..." - npm run e2e - echo "End to end tests completed."
deploy_spa_ss: # This job runs in the deploy stage. stage: deploy # It only runs when *both* jobs in the test stage complete successfully. script: - echo "Deploying application..." - firebase deploy --only hosting:rro-app-2020-ss - echo "Application successfully deployed." only: - /^feature\/.*/ # only deploy commits to feature/ branches deploy_develop: # This job runs in the deploy stage. stage: deploy # It only runs when *both* jobs in the test stage complete successfully. environment: name: develop <<: *node script: - echo "Deploying application to develop..." #- npm run build -e develop - echo "Application successfully deployed." only: - develop # only deploy commits to develop branch
deploy_production: # This job runs in the deploy stage. stage: deploy # It only runs when *both* jobs in the test stage complete successfully. environment: name: production <<: *node script: - echo "Deploying application to production..." #- npm run build -e production - echo "Application successfully deployed." only: - main # only deploy commits to main branch