piwigodotnet/Jenkinsfile

59 lines
1.6 KiB
Plaintext
Raw Normal View History

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 {
stage('preparing workspace') {
2022-10-25 23:08:41 +02:00
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'
}
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 {
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 16:02:46 +01:00
stage('nuget publish') {
// we only publish packages for the main branch
when { branch 'main' }
steps {
sh "dotnet nuget push --source gitea ${env.WORKSPACE}/publish/*.nupkg"
}
}
2022-10-25 22:59:56 +02:00
}
post {
always {
archiveArtifacts artifacts: "publish/*.nupkg", onlyIfSuccessful: true
2022-10-25 22:59:56 +02:00
}
2022-10-25 22:17:59 +02:00
}
}