jenkinsfile from jenkins-playground
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good

This commit is contained in:
adam 2024-11-11 00:34:57 -05:00
parent fc56ddda34
commit 3034e4ddd2
2 changed files with 79 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<IsPackable>true</IsPackable> <IsPackable>true</IsPackable>

78
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,78 @@
pipeline {
agent any
stages {
stage('nuget pack'){
steps{
dotnetPack(outputDirectory: "./", project: "Deployment/Deployment.csproj")
}
}
stage('build numberify'){
steps{
//sed -i 's/<Version>\\([0-9]\\+\\.[0-9]\\)\\.[0-9]\\+<\\/Version>/<Version>\\1.$BUILD_NUMBER<\\/Version>/' nugettest/nugettest.csproj
sh """
filename=\$(ls ./*.nupkg | head -1)
fullfilename=\$(basename -- \$filename)
noext=\${fullfilename%.*}
mv "\$filename" \$noext-\$BUILD_NUMBER.nupkg
filename=null
fullfilename=null
noext=null
"""
}
}
stage('release'){
when {
branch "release"
}
environment {
GITEA = credentials('0bd7c8f5-046c-44b9-9c77-7a28a219ae31')
}
steps{
sh """
filename=\$(ls ./*.nupkg | head -1)
fullfilename=\$(basename -- \$filename)
noext=\${fullfilename%.*}
curl -X 'POST' \
-o release.json \
'https://gitea.arg.rip/api/v1/repos/greyn/deployment/releases' \
-H 'accept: application/json' \
-H 'Authorization: token $GITEA_PSW' \
-H 'Content-Type: application/json' \
-d '{
"body": "automatic build at '"\$(date)"'",
"draft": false,
"name": "$BUILD_NUMBER",
"prerelease": false,
"tag_name": "$BUILD_NUMBER",
"target_commitish": "$GIT_COMMIT"
}'
cat release.json
releaseid=\$(cat release.json | jq .id)
postURL="https://gitea.arg.rip/api/v1/repos/greyn/deployment/releases/\$releaseid/assets?name=\$noext"
curl -X 'POST' \
\$postURL \
-H 'accept: application/json' \
-H 'Authorization: token $GITEA_PSW' \
-H 'Content-Type: multipart/form-data' \
-F "attachment=@\$fullfilename;type=application/nupkg"
releaseid=null
filename=null
fullfilename=null
noext=null
postURL=null
"""
dotnetNuGetPush(root: "./*.nupkg", source:"greyngitea", skipDuplicate:true)
}
}
}
post {
always {
cleanWs()
}
}
}