Compare commits

...

20 Commits

Author SHA1 Message Date
e26c79a9d7 Removed pull event from build stage 2026-04-04 16:39:31 +02:00
ae1440fce3 Refactored uat to staging 2026-04-04 16:38:30 +02:00
b58b5777fd Refactored triggers 2026-04-04 16:38:02 +02:00
83dfdc2cc3 Removed promotion trigger 2026-04-04 16:35:19 +02:00
bbdb27b116 Removed promotion trigger 2026-04-04 16:34:41 +02:00
1da1328870 Removed build stage dependency 2026-04-04 16:29:17 +02:00
3b5ca4f5b0 Removed triggers on build stage 2026-04-04 16:25:09 +02:00
1526648d9a Light refactor 2026-04-04 16:24:12 +02:00
d1f723c135 Added pull_request trigger in build stage 2026-04-04 16:22:59 +02:00
423281d071 Removed push trigger from build branch 2026-04-04 16:19:44 +02:00
44fbc613a3 Enhanced triggers 2026-04-04 16:17:40 +02:00
a922531f50 Fixed pipeline stage naming 2026-04-04 16:13:03 +02:00
9acebb67fe Split deployment from main pipeline 2026-04-04 16:11:17 +02:00
e140319a05 Removed comments 2026-04-04 15:58:58 +02:00
3752da6ebe fixed dotnet step image 2026-04-04 15:58:12 +02:00
1937d2eaa1 Restored drone image detection 2026-04-04 15:56:51 +02:00
c2a8b5c797 removed tags 2026-04-04 15:54:19 +02:00
c584d39270 Applied nexus to all docker references including docker image 2026-04-04 15:51:52 +02:00
81e93b0e4e Refactored nexus trivy manifest 2026-04-04 15:41:54 +02:00
89f619eefa Pointing to the right .net10 image on nexus 2026-04-04 15:40:55 +02:00
2 changed files with 36 additions and 51 deletions

View File

@@ -1,83 +1,68 @@
---
kind: pipeline
type: docker
name: cicd-pipeline
# Let Drone handle the clone automatically; it's faster and cleaner.
clone:
depth: 1
name: build-and-package
steps:
- name: build-test-publish
image: nexus.khongisa.co.za/mcr.microsoft.com/dotnet/sdk:10.0
image: nexus.khongisa.co.za/sdk:10.0
commands:
- dotnet restore --source https://nexus.khongisa.co.za/repository/nuget-group/index.json --no-cache
- dotnet build --configuration Release --no-restore
- dotnet test --configuration Release --no-build
- dotnet publish --configuration Release --no-build
# --- PACKAGE STAGE ---
# We build the image locally first so we can scan it BEFORE pushing
- name: docker-build
- name: docker-build-and-push
image: plugins/docker
settings:
registry: nexus.khongisa.co.za
repo: nexus.khongisa.co.za/webapitest
tags: [ "${DRONE_BUILD_NUMBER}", "latest" ]
username:
from_secret: docker_username
password:
from_secret: docker_password
# This builds the image and loads it into the local cache for scanning
dry_run: true
# Set to false once you verify the scan passes, or see the step below
- name: docker-push
image: plugins/docker
settings:
registry: nexus.khongisa.co.za
repo: nexus.khongisa.co.za/webapitest
tags: [ "${DRONE_BUILD_NUMBER}", "latest" ]
username:
from_secret: docker_username
password:
from_secret: docker_password
username: { from_secret: docker_username }
password: { from_secret: docker_password }
- name: vulnerability-scan
image: nexus.khongisa.co.za/aquasec/trivy:0.50.1
image: aquasec/trivy:0.50.1
environment:
# Trivy needs these to pull the image from your Nexus to scan it
TRIVY_USERNAME:
from_secret: docker_username
TRIVY_PASSWORD:
from_secret: docker_password
TRIVY_USERNAME: { from_secret: docker_username }
TRIVY_PASSWORD: { from_secret: docker_password }
commands:
- trivy image --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER}
- trivy image --image-src remote --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER}
# --- DEPLOY STAGE ---
- name: deploy-uat
trigger:
branch:
- main
event:
exclude:
- promote
---
kind: pipeline
type: docker
name: deploy-to-uat
depends_on:
- build-and-package
steps:
- name: uat-deployment
image: appleboy/drone-ssh
settings:
host:
from_secret: ssh_host
username:
from_secret: ssh_user
password:
from_secret: ssh_password
host: { from_secret: ssh_host }
username: { from_secret: ssh_user }
password: { from_secret: ssh_password }
script:
# Login to Nexus on the remote server
- echo $DOCKER_PASSWORD | docker login nexus.khongisa.co.za -u $DOCKER_USERNAME --password-stdin
- docker pull nexus.khongisa.co.za/webapitest:latest
# Standard Linux cleanup
- docker stop webapi 2>/dev/null || true
- docker rm webapi 2>/dev/null || true
- docker run -d --name webapi --restart unless-stopped -e ASPNETCORE_ENVIRONMENT=Development -p 4000:8081 nexus.khongisa.co.za/webapitest:latest
environment:
DOCKER_USERNAME:
from_secret: docker_username
DOCKER_PASSWORD:
from_secret: docker_password
DOCKER_USERNAME: { from_secret: docker_username }
DOCKER_PASSWORD: { from_secret: docker_password }
trigger:
event:
exclude:
- promote
- promote
target:
- staging

View File

@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
FROM nexus.khongisa.co.za/aspnet:10.0 AS final
WORKDIR /app
USER app