piwigodotnet/Jenkinsfile

61 lines
2.1 KiB
Plaintext
Raw Permalink 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 {
sh "dotnet pack ${env.WORKSPACE}/src/PiwigoDotnet.sln --no-restore -c Release -o ${env.WORKSPACE}/publish/nuget -p:Version=${env.PWDNVERSION}.${env.BUILD_NUMBER}"
2022-12-11 21:59:55 +01:00
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.PWDNVERSION}.${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.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/nuget/*.nupkg"
}
}
2022-10-25 22:59:56 +02:00
}
post {
always {
archiveArtifacts artifacts: "publish/**/*", onlyIfSuccessful: true
2022-10-25 22:59:56 +02:00
}
2022-10-25 22:17:59 +02:00
}
}