Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- node {
- def sourceBranch = ""
- try{
- sourceBranch = "${BITBUCKET_SOURCE_BRANCH}";
- }catch(e){}
- if(sourceBranch == ""){
- sourceBranch = 'development'
- }
- checkout changelog: true, poll: true, scm: [
- $class: 'GitSCM',
- branches: [
- [name: '*/'+sourceBranch]
- ],
- doGenerateSubmoduleConfigurations: false,
- submoduleCfg: [],
- userRemoteConfigs: [
- [
- credentialsId: '42900341-f9b5-4a0f-9d41-f5c7a13beae0',
- url: 'https://inspireitadmin@bitbucket.org/inspireitadmin/inspireit.attributes.git'
- ]
- ]]
- }
- pipeline {
- agent any
- stages {
- stage('build') {
- steps{
- script {
- try {
- dir("D:/DevOps/jenkins/workspace/InspireIT.Attributes/InspireIT.Attributes/") {
- bat "dotnet restore -s http://nuget.inspireit.pt/v3/index.json -s https://api.nuget.org/v3/index.json"
- bat "dotnet build"
- }
- }
- catch (Exception e) {
- bitbucketStatusNotify(buildState: 'FAILED')
- error("Build failed")
- }
- bitbucketStatusNotify(buildState: 'INPROGRESS')
- }
- }
- }
- stage('tests') {
- steps{
- script {
- try {
- dir("D:/DevOps/jenkins/workspace/InspireIT.Attributes/InspireIT.Attributes/"){
- bat "D:/DevOps/jenkins/workspace/scripts/add-coverlet-to-test.bat"
- bat "dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=\"./coverage.opencover.xml\" -c Release"
- }
- }
- catch (Exception e) {
- bitbucketStatusNotify(buildState: 'FAILED')
- error("Build failed")
- }
- bitbucketStatusNotify(buildState: 'INPROGRESS')
- }
- }
- }
- stage('sonar') {
- steps{
- script {
- try {
- dir("D:/DevOps/jenkins/workspace/InspireIT.Attributes/InspireIT.Attributes/") {
- 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\""
- bat "dotnet restore -s http://nuget.inspireit.pt/v3/index.json -s https://api.nuget.org/v3/index.json"
- bat "dotnet build"
- bat "dotnet sonarscanner end /d:sonar.login=7b79d25593101e8470a7f93cacf5dd3c5917b171"
- bat "del /s coverage.opencover*"
- }
- bitbucketStatusNotify(buildState: 'SUCCESSFUL')
- }
- catch (Exception e) {
- bitbucketStatusNotify(buildState: 'FAILED')
- error("Build failed")
- }
- }
- }
- }
- stage('deploy&Tagging') {
- steps{
- script {
- try {
- if (env.BITBUCKET_SOURCE_BRANCH == 'master') {
- bat 'D:\\DevOps\\NugetNewRelease\\InspireIT.Attributes\\attributes.bat'
- }
- }
- catch (Exception e) {
- bitbucketStatusNotify(buildState: 'FAILED')
- error("Build failed")
- }
- bitbucketStatusNotify(buildState: 'SUCCESSFUL')
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement