-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
81 lines (68 loc) · 2.62 KB
/
azure-pipelines.yml
File metadata and controls
81 lines (68 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'package'
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
# Lire la version actuelle à partir du fichier
$versionFilePath = "$(Build.SourcesDirectory)/version.txt"
$version = Get-Content $versionFilePath
# Diviser la version en parties : majeure, mineure, patch
$versionParts = $version -split '\.'
$major = [int]$versionParts[0]
$minor = [int]$versionParts[1]
$patch = [int]$versionParts[2]
# Afficher la version actuelle
echo "Version actuelle : $major.$minor.$patch"
# Décider de la partie à incrémenter (ici le patch)
$patch++
# Si un changement du numéro mineur est détecté, incrémenter le mineur et remettre le patch à zéro
if ($env:NEW_MINOR -and $minor -ne $env:NEW_MINOR) {
echo "Incrémentation de la version mineure..."
$minor = [int]$env:NEW_MINOR
$patch = 0
$newVersion = "$major.$minor.$patch-rc"
} else {
echo "Aucune modification de la version mineure, incrémentation du patch..."
$patch++
$newVersion = "$major.$minor.$patch"
}
# Construire la nouvelle version
$newVersion = "$major.$minor.$patch"
echo "Nouvelle version : $newVersion"
# Mettre à jour le fichier avec la nouvelle version
Set-Content -Path $versionFilePath -Value $newVersion
# Enregistrer la nouvelle version dans la variable de build
echo "##vso[task.setvariable variable=version]$newVersion"
displayName: 'Incrémenter le patch dans version.txt'
- script: |
git config --global user.name "jamil"
git config --global user.email "abidijamil@gmail.com"
git remote set-url origin "https://$(GITHUB_TOKEN)@github.com/jamilabidi/pipelines-java"
git add version.txt
git commit -m "Incrémentation de la version à $(version)"
git push origin HEAD:main
displayName: 'Valider et pousser le fichier de version'
- task: DotNetCoreCLI@2
inputs:
command: 'pack'
packagesToPack: '**/*.csproj'
versioningScheme: 'byBuild'
version: $(version)