Automating Devops With Gitlab Ci/cd Pipelines Read Online Site

test: script: npm test artifacts: reports: junit: junit.xml paths: - coverage/ expire_in: 1 week GitLab can even display test reports directly in merge requests! One of the most powerful automation patterns is building and pushing Docker images. Example: Build and Push to GitLab Container Registry stages: - build-image - scan - deploy variables: IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA

test_job: stage: test script: - npm run test automating devops with gitlab ci/cd pipelines read online

curl --request POST --form "token=$CI_JOB_TOKEN" --form "ref=main" "https://gitlab.com/api/v4/projects/123/trigger/pipeline" This allows external systems (monitoring, chatops) to start pipelines. DevOps automation must include security. GitLab provides native security scanning. SAST (Static Application Security Testing) Add to your pipeline: test: script: npm test artifacts: reports: junit: junit

deploy: stage: deploy trigger: project: backend/infra branch: main strategy: depend You can trigger a pipeline via API with a token: DevOps automation must include security

deploy_staging: stage: deploy script: kubectl apply -f k8s/staging/ environment: name: staging url: https://staging.myapp.com deploy_prod: stage: deploy script: kubectl apply -f k8s/prod/ environment: name: production url: https://myapp.com rules: - if: $CI_COMMIT_TAG

include: - template: Security/Secret-Detection.gitlab-ci.yml These security jobs run automatically, enforcing "shift-left" security. Environments Track deployments by defining environments:

workflow: rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never - if: $CI_COMMIT_BRANCH Now each merge request runs a full pipeline, and GitLab blocks merging if tests fail. Modern applications often consist of multiple microservices. GitLab supports cross-project automation. Triggering a downstream pipeline In project A (frontend):