piwigodotnet/Jenkinsfile
Philipp Häfelfinger f68355a966
Some checks failed
piwigodotnet/pipeline/head There was a failure building this commit
only publish packages on main branch
2022-11-03 15:32:42 +01:00

60 lines
1.6 KiB
Groovy

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 -p:Version=${env.PWDNVERSION}.${env.BUILD_NUMBER}"
}
}
// 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"
}
}
}
}
post {
always {
archiveArtifacts artifacts: "publish/*.nupkg", onlyIfSuccessful: true
}
}
}