Advertisement
Guest User

Pipeline com nuger release

a guest
Feb 21st, 2020
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. node {
  2. def sourceBranch = ""
  3. try{
  4. sourceBranch = "${BITBUCKET_SOURCE_BRANCH}";
  5.  
  6. }catch(e){}
  7.  
  8. if(sourceBranch == ""){
  9. sourceBranch = 'development'
  10. }
  11.  
  12. checkout changelog: true, poll: true, scm: [
  13. $class: 'GitSCM',
  14. branches: [
  15. [name: '*/'+sourceBranch]
  16. ],
  17. doGenerateSubmoduleConfigurations: false,
  18. submoduleCfg: [],
  19. userRemoteConfigs: [
  20. [
  21. credentialsId: '42900341-f9b5-4a0f-9d41-f5c7a13beae0',
  22. url: 'https://inspireitadmin@bitbucket.org/inspireitadmin/inspireit.attributes.git'
  23. ]
  24. ]]
  25. }
  26. pipeline {
  27. agent any
  28. stages {
  29. stage('build') {
  30. steps{
  31. script {
  32. try {
  33. dir("D:/DevOps/jenkins/workspace/InspireIT.Attributes/InspireIT.Attributes/") {
  34. bat "dotnet restore -s http://nuget.inspireit.pt/v3/index.json -s https://api.nuget.org/v3/index.json"
  35. bat "dotnet build"
  36. }
  37. }
  38. catch (Exception e) {
  39. bitbucketStatusNotify(buildState: 'FAILED')
  40. error("Build failed")
  41. }
  42. bitbucketStatusNotify(buildState: 'INPROGRESS')
  43. }
  44. }
  45. }
  46. stage('tests') {
  47. steps{
  48. script {
  49. try {
  50. dir("D:/DevOps/jenkins/workspace/InspireIT.Attributes/InspireIT.Attributes/"){
  51. bat "D:/DevOps/jenkins/workspace/scripts/add-coverlet-to-test.bat"
  52. bat "dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=\"./coverage.opencover.xml\" -c Release"
  53. }
  54. }
  55. catch (Exception e) {
  56. bitbucketStatusNotify(buildState: 'FAILED')
  57. error("Build failed")
  58. }
  59. bitbucketStatusNotify(buildState: 'INPROGRESS')
  60. }
  61. }
  62. }
  63. stage('sonar') {
  64. steps{
  65. script {
  66. try {
  67. dir("D:/DevOps/jenkins/workspace/InspireIT.Attributes/InspireIT.Attributes/") {
  68. bat "dotnet sonarscanner begin /k:InspireIT.Attributes /d:sonar.host.url=http://sonar.inspireit.pt /d:sonar.login=7b79d25593101e8470a7f93cacf5dd3c5917b171 /d:sonar.cs.opencover.reportsPaths=\"**/coverage.opencover.xml\""
  69. bat "dotnet restore -s http://nuget.inspireit.pt/v3/index.json -s https://api.nuget.org/v3/index.json"
  70. bat "dotnet build"
  71. bat "dotnet sonarscanner end /d:sonar.login=7b79d25593101e8470a7f93cacf5dd3c5917b171"
  72. bat "del /s coverage.opencover*"
  73. }
  74. bitbucketStatusNotify(buildState: 'SUCCESSFUL')
  75. }
  76. catch (Exception e) {
  77. bitbucketStatusNotify(buildState: 'FAILED')
  78. error("Build failed")
  79. }
  80. }
  81. }
  82. }
  83. stage('deploy&Tagging') {
  84. steps{
  85. script {
  86. try {
  87. if (env.BITBUCKET_SOURCE_BRANCH == 'master') {
  88. bat 'D:\\DevOps\\NugetNewRelease\\InspireIT.Attributes\\attributes.bat'
  89. }
  90. }
  91. catch (Exception e) {
  92. bitbucketStatusNotify(buildState: 'FAILED')
  93. error("Build failed")
  94. }
  95. bitbucketStatusNotify(buildState: 'SUCCESSFUL')
  96. }
  97. }
  98. }
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement