jenkins-playground/Jenkinsfile
adam cb5ae43d2a
All checks were successful
gitea.arg.rip/jenkins-playground/pipeline/head This commit looks good
apostrophes for string building
2024-11-10 02:07:58 -05:00

76 lines
2.6 KiB
Groovy

pipeline {
agent any
stages {
stage('nuget pack'){
steps{
dotnetPack(outputDirectory: "./", project: "nugettest/")
}
}
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_PAT = 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/jenkins-playground/releases?token=$GITEA_PAT' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"body": "\$(date)",
"draft": false,
"name": "$BUILD_NUMBER",
"prerelease": false,
"tag_name": "$BUILD_NUMBER",
"target_commitish": "$GIT_COMMIT"
}'
releaseid=\$(cat release.json | jq .id)
postURL = "https://gitea.arg.rip/api/v1/repos/greyn/jenkins-playground/releases/\$releaseid/assets?name=\$noext&token=$GITEA_PAT"
curl -X 'POST' \
\$postURL \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'attachment=@\$fullfilename'
releaseid=null
filename=null
fullfilename=null
noext=null
postURL=null
"""
dotnetNuGetPush(root: "./*.nupkg", source:"greyngitea", skipDuplicate:true)
}
}
}
post {
always {
cleanWs()
}
}
}