pipeline { agent { docker { image 'mcr.microsoft.com/dotnet/sdk:6.0'} } environment { PWDNVERSION = "0.1.0" // home is required to make dotnet work as if undived / is used which is not accessible HOME = "${env.WORKSPACE}" } stages { stage('preparing workspace') { steps { cleanWs deleteDirs: true, notFailBuild: true, patterns: [[pattern: '.nuget/NuGet/NuGet.Config', type: 'INCLUDE']] dir('publish') { deleteDir() } withCredentials([usernamePassword(credentialsId: 'giteaNugetPushCreds', passwordVariable: 'NUGETPWD', usernameVariable: 'NUGETUSR')]) { sh 'dotnet nuget add source --name gitea --username $NUGETUSR --password $NUGETPWD --store-password-in-clear-text https://git.haefelfinger.net/api/packages/piwigo/nuget/index.json' } } } stage('nuget restore') { steps { sh "dotnet restore ${env.WORKSPACE}/src/PiwigoDotnet.sln" } } stage('test') { steps { sh "dotnet test ${env.WORKSPACE}/src/PiwigoDotnet.sln --no-restore" } } stage('packing') { steps { sh "dotnet pack ${env.WORKSPACE}/src/PiwigoDotnet.sln --no-restore -c Release -o ${env.WORKSPACE}/publish/nuget -p:Version=${env.PWDNVERSION}.${env.BUILD_NUMBER}" sh "dotnet publish ${env.WORKSPACE}/src/Piwigo.Client.Cli/Piwigo.Client.Cli.csproj -c Release --self-contained true -r linux-x64 -o ${env.WORKSPACE}/publish/cli-linux -p:Version=${env.APPVERSION}.${env.BUILD_NUMBER}" sh "dotnet publish ${env.WORKSPACE}/src/Piwigo.Client.Cli/Piwigo.Client.Cli.csproj -c Release --self-contained true -r win-x64 -o ${env.WORKSPACE}/publish/cli-win -p:Version=${env.APPVERSION}.${env.BUILD_NUMBER}" } } stage('nuget publish') { // we only publish packages for the main branch when { branch 'main' } steps { sh "dotnet nuget push --source gitea ${env.WORKSPACE}/publish/nuget/*.nupkg" } } } post { always { archiveArtifacts artifacts: "publish/**/*", onlyIfSuccessful: true } } }