test #95

Merged
khwezi merged 2 commits from test into main 2026-04-04 15:59:26 +02:00

View File

@@ -2,21 +2,18 @@ kind: pipeline
type: docker type: docker
name: cicd-pipeline name: cicd-pipeline
# Let Drone handle the clone automatically; it's faster and cleaner.
clone: clone:
depth: 1 depth: 1
steps: steps:
- name: build-test-publish - 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: commands:
- dotnet restore --source https://nexus.khongisa.co.za/repository/nuget-group/index.json --no-cache - dotnet restore --source https://nexus.khongisa.co.za/repository/nuget-group/index.json --no-cache
- dotnet build --configuration Release --no-restore - dotnet build --configuration Release --no-restore
- dotnet test --configuration Release --no-build - dotnet test --configuration Release --no-build
- dotnet publish --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
image: plugins/docker image: plugins/docker
settings: settings:
@@ -27,9 +24,7 @@ steps:
from_secret: docker_username from_secret: docker_username
password: password:
from_secret: docker_password from_secret: docker_password
# This builds the image and loads it into the local cache for scanning
dry_run: true dry_run: true
# Set to false once you verify the scan passes, or see the step below
- name: docker-push - name: docker-push
image: plugins/docker image: plugins/docker
@@ -45,7 +40,6 @@ steps:
- name: vulnerability-scan - name: vulnerability-scan
image: aquasec/trivy:0.50.1 image: aquasec/trivy:0.50.1
environment: environment:
# Trivy needs these to pull the image from your Nexus to scan it
TRIVY_USERNAME: TRIVY_USERNAME:
from_secret: docker_username from_secret: docker_username
TRIVY_PASSWORD: TRIVY_PASSWORD:
@@ -53,7 +47,6 @@ steps:
commands: commands:
- trivy image --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER} - trivy image --exit-code 1 --severity CRITICAL nexus.khongisa.co.za/webapitest:${DRONE_BUILD_NUMBER}
# --- DEPLOY STAGE ---
- name: deploy-uat - name: deploy-uat
image: appleboy/drone-ssh image: appleboy/drone-ssh
settings: settings:
@@ -64,10 +57,8 @@ steps:
password: password:
from_secret: ssh_password from_secret: ssh_password
script: script:
# Login to Nexus on the remote server
- echo $DOCKER_PASSWORD | docker login nexus.khongisa.co.za -u $DOCKER_USERNAME --password-stdin - echo $DOCKER_PASSWORD | docker login nexus.khongisa.co.za -u $DOCKER_USERNAME --password-stdin
- docker pull nexus.khongisa.co.za/webapitest:latest - docker pull nexus.khongisa.co.za/webapitest:latest
# Standard Linux cleanup
- docker stop webapi 2>/dev/null || true - docker stop webapi 2>/dev/null || true
- docker rm 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 - docker run -d --name webapi --restart unless-stopped -e ASPNETCORE_ENVIRONMENT=Development -p 4000:8081 nexus.khongisa.co.za/webapitest:latest