charts/pipelines-library/templates/tasks/edp-dotnet.yaml (61 lines of code) (raw):
{{ if .Values.pipelines.deployableResources.tasks }}
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: edp-dotnet
labels:
{{- include "edp-tekton.labels" . | nindent 4 }}
annotations:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/displayName: DotNet
tekton.dev/categories: Build Tools
tekton.dev/tags: build-tool
tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le"
spec:
description: >-
This task builds and tests a .NET project using a specified base image, with support for caching dependencies and running coverage analysis on test projects.
workspaces:
- name: source
description: The workspace consisting of the dotnet project.
params:
- name: BASE_IMAGE
description: DotNet base image.
type: string
default: "mcr.microsoft.com/dotnet/sdk:3.1.423-alpine3.16"
- name: PROJECT_DIR
description: The directory containing build.gradle
type: string
default: "source"
- name: DOTNET_CACHE
type: string
description: name of the secret for the Sonarqube integration
default: "/workspace/source/cache"
steps:
- name: build
image: $(params.BASE_IMAGE)
workingDir: $(workspaces.source.path)/$(params.PROJECT_DIR)
env:
- name: HOME
value: $(workspaces.source.path)
- name: DOTNET_CACHE
value: $(params.DOTNET_CACHE)
script: |
#!/usr/bin/env sh
set -e
dotnet restore --packages ${DOTNET_CACHE}
dotnet build
- name: test
image: $(params.BASE_IMAGE)
workingDir: $(workspaces.source.path)/$(params.PROJECT_DIR)
env:
- name: HOME
value: $(workspaces.source.path)
- name: DOTNET_CACHE
value: $(params.DOTNET_CACHE)
script: |
#!/usr/bin/env sh
set -e
dotnet restore --packages ${DOTNET_CACHE}
ls *Tests*/*.csproj | while read -r file;
do dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover "${file}";
done
{{- include "resources" . | nindent 6 }}
{{ end }}