Skip to content

Commit

Permalink
💚 updates ci flow
Browse files Browse the repository at this point in the history
  • Loading branch information
ThiagoBarradas committed Jul 8, 2020
1 parent 51f208f commit 6709f7d
Showing 1 changed file with 65 additions and 21 deletions.
86 changes: 65 additions & 21 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# - for linux environment

variables:
organization: 'barradas'
solution_path: 'RestSharp.Easy.sln'
sdk_project_name: 'RestSharp.Easy'
sdk_project_path: 'RestSharp.Easy/RestSharp.Easy.csproj'
Expand All @@ -20,13 +21,20 @@ variables:
sonarcloud_account: 'SonarCloudBarradas'

trigger:
- release/*
- hotfix/*
- master
- develop
branches:
include:
- release/*
- hotfix/*
- develop
tags:
include:
- '*'

pr:
- develop
branches:
include:
- develop
- master

pool:
vmImage: 'ubuntu-latest'
Expand All @@ -40,12 +48,15 @@ stages:
variables:
current_counter: $[counter(variables['Build.SourceBranchName'], 1)]
steps:
- task: gittools.gitversion.gitversion-task.GitVersion@5
condition: eq(variables['Build.SourceBranchName'], 'master')
displayName: 'Get version from git tag for master'
inputs:
updateAssemblyInfo: false
- bash: |
if [[ "$(Build.SourceVersionMessage)" =~ "hotfix/" ]];
then
echo "##vso[task.setvariable variable=IsHotfix;isOutput=true]true"
echo "##vso[task.setvariable variable=PreviousPrefix;isOutput=true]hotfix"
else
echo "##vso[task.setvariable variable=IsHotfix;isOutput=true]false"
echo "##vso[task.setvariable variable=PreviousPrefix;isOutput=true]release"
fi
if [[ "$(Build.SourceBranch)" =~ "/hotfix/" ]] ||
[[ "$(Build.SourceBranch)" =~ "/release/" ]];
then
Expand All @@ -54,21 +65,40 @@ stages:
echo " $(Build.SourceBranchName)-preview.$(current_counter)"
echo "##vso[build.updatebuildnumber]$(Build.SourceBranchName)-preview.$(current_counter)"
echo "##vso[task.setvariable variable=PureVersion;isOutput=true]$(Build.SourceBranchName)"
elif [ "$(Build.SourceBranchName)" = "master" ];
elif [[ "$(Build.SourceBranch)" =~ "/tags/" ]];
then
echo "Generate Release Version"
echo "Version: $(GitVersion.SemVer)"
echo "##vso[build.updatebuildnumber]$(GitVersion.SemVer)"
echo "##vso[task.setvariable variable=PureVersion;isOutput=true]$(GitVersion.SemVer)"
echo "Version: $(Build.SourceBranchName)"
echo "##vso[build.updatebuildnumber]$(Build.SourceBranchName)"
echo "##vso[task.setvariable variable=SonarMasterWhenTag;isOutput=true]sonar.branch.name=master"
echo "##vso[task.setvariable variable=PureVersion;isOutput=true]$(Build.SourceBranchName)"
else
echo "Generate Development Version"
echo "Version: $(Build.BuildNumber)"
echo "##vso[build.updatebuildnumber]$(Build.BuildNumber)-develop"
echo "Version: $(Build.BuildNumber)-develop"
fi
displayName: Update Version Number
name: UpdateBuildVersionTask
- bash: |
STAGING_URL="https://dev.azure.com/$(organization)/$(System.TeamProject)/_apis/build/status/$(System.DefinitionId)?branchName=$(UpdateBuildVersionTask.PreviousPrefix)/$(Build.BuildNumber)&stageName=DeployPackage"
STAGING_RESULT=$`curl --silent $STAGING_URL`
echo "URL: $STAGING_URL"
echo "RESULT: $STAGING_RESULT"
SUCCEEDED=$`echo $STAGING_RESULT | grep -P 'succeeded' -o | head -n 1`
if [[ "$STAGING_RESULT" =~ "succeeded" ]];
then
echo "$PREVIOUS_PREFIX branch is ok!"
else
echo "$PREVIOUS_PREFIX branch is not ok!"
exit 1
fi
condition: contains(variables['Build.SourceBranch'], '/tags/')
displayName: Break if release/hotfix branch is not passing
name: BreakIsReleaseOrHotfixIsNotPassing
- job: Build
dependsOn: UpdateBuildVersion
dependsOn:
- UpdateBuildVersion
condition: succeeded()
workspace:
clean: all
Expand All @@ -87,7 +117,9 @@ stages:
artifact: $(sdk_project_name)

- job: UnitTests
dependsOn: Build
dependsOn:
- UpdateBuildVersion
- Build
workspace:
clean: all
condition: and(succeeded(), eq(variables['execute_test'], 'true'))
Expand Down Expand Up @@ -129,16 +161,22 @@ stages:
testRunTitle: 'Collecting Test Results'

- job: QualityAnalysis
dependsOn: UnitTests
dependsOn:
- UpdateBuildVersion
- Build
- UnitTests
condition: |
and
(
in(dependencies.UpdateBuildVersion.result, 'Succeeded'),
in(dependencies.Build.result, 'Succeeded', 'Skipped'),
in(dependencies.UnitTests.result, 'Succeeded', 'Skipped'),
eq(variables['execute_sonarcloud'], 'true')
)
workspace:
clean: all
variables:
SonarMasterWhenTag: $[ dependencies.UpdateBuildVersion.outputs['UpdateBuildVersionTask.SonarMasterWhenTag'] ]
OpencoverSonar: $[ dependencies.UnitTests.outputs['UnitTestsTask.OpencoverSonar'] ]
steps:
- task: DownloadPipelineArtifact@2
Expand All @@ -158,6 +196,7 @@ stages:
sonar.sourceEncoding=UTF-8
sonar.scm.forceReloadAll=true
$(OpencoverSonar)
$(SonarMasterWhenTag)
- script: |
dotnet build "$(solution_path)"
displayName: Runnig Build For Analysis
Expand All @@ -174,19 +213,24 @@ stages:

- job: PackingNuget
dependsOn:
- QualityAnalysis
- UpdateBuildVersion
- Build
- UnitTests
- QualityAnalysis
workspace:
clean: all
condition: |
and
(
eq(dependencies.UpdateBuildVersion.result, 'Succeeded'),
in(dependencies.Build.result, 'Succeeded', 'Skipped'),
in(dependencies.UnitTests.result, 'Succeeded', 'Skipped'),
in(dependencies.QualityAnalysis.result, 'Succeeded', 'Skipped'),
or
(
contains(variables['Build.SourceBranch'], '/hotfix/'),
contains(variables['Build.SourceBranch'], '/release/'),
eq(variables['Build.SourceBranchName'], 'master')
contains(variables['Build.SourceBranch'], '/tags/')
)
)
variables:
Expand Down Expand Up @@ -216,7 +260,7 @@ stages:
(
contains(variables['Build.SourceBranch'], '/hotfix/'),
contains(variables['Build.SourceBranch'], '/release/'),
eq(variables['Build.SourceBranchName'], 'master')
contains(variables['Build.SourceBranch'], '/tags/')
)
)
variables:
Expand Down

0 comments on commit 6709f7d

Please sign in to comment.