2022-10-25 22:17:59 +02:00
|
|
|
pipeline {
|
|
|
|
agent {
|
2022-10-25 22:31:58 +02:00
|
|
|
docker { image 'mcr.microsoft.com/dotnet/sdk:6.0'}
|
2022-10-25 22:17:59 +02:00
|
|
|
}
|
|
|
|
|
2022-10-25 22:41:49 +02:00
|
|
|
environment {
|
2022-10-25 22:59:56 +02:00
|
|
|
PWDNVERSION = "0.1.0"
|
|
|
|
// home is required to make dotnet work as if undived / is used which is not accessible
|
2022-10-25 22:44:52 +02:00
|
|
|
HOME = "${env.WORKSPACE}"
|
2022-10-25 22:41:49 +02:00
|
|
|
}
|
|
|
|
|
2022-10-25 22:17:59 +02:00
|
|
|
stages {
|
2022-11-03 15:17:33 +01:00
|
|
|
stage('preparing workspace') {
|
2022-10-25 23:08:41 +02:00
|
|
|
steps {
|
2022-11-03 15:17:33 +01:00
|
|
|
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'
|
|
|
|
}
|
2022-10-25 23:08:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-25 22:17:59 +02:00
|
|
|
stage('nuget restore') {
|
|
|
|
steps {
|
2022-10-25 22:43:46 +02:00
|
|
|
sh "dotnet restore ${env.WORKSPACE}/src/PiwigoDotnet.sln"
|
2022-10-25 22:17:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-25 22:59:56 +02:00
|
|
|
stage('test') {
|
|
|
|
steps {
|
2022-10-25 23:03:39 +02:00
|
|
|
sh "dotnet test ${env.WORKSPACE}/src/PiwigoDotnet.sln --no-restore"
|
2022-10-25 22:59:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('packing') {
|
|
|
|
steps {
|
2022-10-25 23:20:07 +02:00
|
|
|
sh "dotnet pack ${env.WORKSPACE}/src/PiwigoDotnet.sln --no-restore -c Release -o ${env.WORKSPACE}/publish -p:Version=${env.PWDNVERSION}.${env.BUILD_NUMBER}"
|
2022-10-25 22:59:56 +02:00
|
|
|
}
|
|
|
|
}
|
2022-10-25 22:17:59 +02:00
|
|
|
|
2022-11-03 15:32:42 +01:00
|
|
|
// we only publish packages for the main branch
|
|
|
|
if (env.BRANCH_NAME == 'main') {
|
|
|
|
stage('nuget publish') {
|
|
|
|
steps {
|
|
|
|
sh "dotnet nuget push --source gitea ${env.WORKSPACE}/publish/*.nupkg"
|
|
|
|
}
|
2022-11-03 15:17:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-25 22:59:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
post {
|
|
|
|
always {
|
2022-10-25 23:03:39 +02:00
|
|
|
archiveArtifacts artifacts: "publish/*.nupkg", onlyIfSuccessful: true
|
2022-10-25 22:59:56 +02:00
|
|
|
}
|
2022-10-25 22:17:59 +02:00
|
|
|
}
|
|
|
|
}
|