From 3034e4ddd2fcdbb12bd2ea0f8ccfb0efde5cdaae Mon Sep 17 00:00:00 2001 From: adam Date: Mon, 11 Nov 2024 00:34:57 -0500 Subject: [PATCH] jenkinsfile from jenkins-playground --- Deployment/Deployment.csproj | 2 +- Jenkinsfile | 78 ++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 Jenkinsfile diff --git a/Deployment/Deployment.csproj b/Deployment/Deployment.csproj index 19044ac..531463d 100644 --- a/Deployment/Deployment.csproj +++ b/Deployment/Deployment.csproj @@ -1,7 +1,7 @@  - net8.0 + net7.0 enable enable true diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..561a080 --- /dev/null +++ b/Jenkinsfile @@ -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/\\([0-9]\\+\\.[0-9]\\)\\.[0-9]\\+<\\/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() + } + } +}