Compare commits

...

28 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
b46848dd56 Refactored the pipeline to pull the trivy image from nexus as well 2026-04-04 15:33:03 +02:00
30e0bc2b87 Pulling .net docker image from nexus 2026-04-04 15:32:20 +02:00
903c17e7f8 Refactored the pipeline so that docker push happens before the trivy scan 2026-04-04 15:30:56 +02:00
bd3cba05cb Fixed docker steps to use local nexus properly 2026-04-04 15:24:06 +02:00
007f606bb6 Supplied full package source for nuget 2026-04-04 15:12:55 +02:00
ef6262282d Applied specific trivy version 2026-04-04 15:10:28 +02:00
502182a370 Using nexus for dotnet restore 2026-04-04 15:09:05 +02:00
c6799a146a Added publish step to dotnet 2026-04-04 15:06:32 +02:00
2 changed files with 43 additions and 57 deletions

View File

@@ -1,82 +1,68 @@
---
kind: pipeline kind: pipeline
type: docker type: docker
name: cicd-pipeline name: build-and-package
# Let Drone handle the clone automatically; it's faster and cleaner.
clone:
depth: 1
steps: steps:
# --- BUILD & TEST STAGE --- - name: build-test-publish
- name: build-and-test image: nexus.khongisa.co.za/sdk:10.0
image: mcr.microsoft.com/dotnet/sdk:10.0
commands: commands:
- dotnet build --configuration Release - dotnet restore --source https://nexus.khongisa.co.za/repository/nuget-group/index.json --no-cache
- dotnet test --configuration Release - dotnet build --configuration Release --no-restore
- dotnet test --configuration Release --no-build
- dotnet publish --configuration Release --no-build
# --- PACKAGE STAGE --- - name: docker-build-and-push
# We build the image locally first so we can scan it BEFORE pushing
- name: docker-build
image: plugins/docker image: plugins/docker
settings: settings:
registry: nexus.khongisa.co.za registry: nexus.khongisa.co.za
repo: nexus.khongisa.co.za/mngomalab/webapitest repo: nexus.khongisa.co.za/webapitest
tags: [ "${DRONE_BUILD_NUMBER}", "latest" ] tags: [ "${DRONE_BUILD_NUMBER}", "latest" ]
username: username: { from_secret: docker_username }
from_secret: docker_username password: { from_secret: docker_password }
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: vulnerability-scan - name: vulnerability-scan
image: aquasec/trivy image: aquasec/trivy:0.50.1
environment: environment:
# Trivy needs these to pull the image from your Nexus to scan it TRIVY_USERNAME: { from_secret: docker_username }
TRIVY_USERNAME: TRIVY_PASSWORD: { from_secret: docker_password }
from_secret: docker_username
TRIVY_PASSWORD:
from_secret: docker_password
commands: commands:
- trivy image --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/mngomalab/webapitest:${DRONE_BUILD_NUMBER} - trivy image --image-src remote --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER}
- name: docker-push
image: plugins/docker
settings:
registry: nexus.khongisa.co.za
repo: nexus.khongisa.co.za/mngomalab/webapitest
tags: [ "${DRONE_BUILD_NUMBER}", "latest" ]
username:
from_secret: docker_username
password:
from_secret: docker_password
# --- DEPLOY STAGE ---
- name: deploy-uat
image: appleboy/drone-ssh
settings:
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/mngomalab/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/mngomalab/webapitest:latest
environment:
DOCKER_USERNAME:
from_secret: docker_username
DOCKER_PASSWORD:
from_secret: docker_password
trigger: trigger:
branch:
- main
event: event:
exclude: exclude:
- promote - 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 }
script:
- echo $DOCKER_PASSWORD | docker login nexus.khongisa.co.za -u $DOCKER_USERNAME --password-stdin
- docker pull nexus.khongisa.co.za/webapitest:latest
- 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 }
trigger:
event:
- 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 WORKDIR /app
USER app USER app