Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ALM Accelerator - Feature]: Customise Solution Version number post deployment to ALM #7553

Closed
iamaninda93 opened this issue Jan 29, 2024 · 12 comments
Assignees
Labels
alm-accelerator ALM Accelerator Components and Apps enhancement New feature or request

Comments

@iamaninda93
Copy link

iamaninda93 commented Jan 29, 2024

Is your feature request related to a problem? Please describe.

Every time when we set up ALM of a new solution in AzDO we need to correct the versioning manually in the copied coe pipelines of the solution. This we don't want. We want the solution to have pipelines with the correct version number format YYYYMMDD.count.

Solutions deployed with the ALM Accelerator adhere to the version number format YYYYMMDD.countSolutions deployed to environments by the ALM Accelerator tools have the wrong version number format. It should be YYYYMMDD.revision but it is 1.0.YYYYMMDD.revision.

Describe the solution you'd like

Solutions deployed with the ALM Accelerator adhere to the version number format YYYYMMDD.count. Solutions deployed to environments by the ALM Accelerator tools have the wrong version number format. It should be YYYYMMDD.revision but it is 1.0.YYYYMMDD.revision.

Describe alternatives you've considered

Every time we need to change the format manually for each application.
01gb9gvr

Additional context?

No response

AB#2152

@iamaninda93 iamaninda93 added alm-accelerator ALM Accelerator Components and Apps enhancement New feature or request labels Jan 29, 2024
@RajeevPentyala RajeevPentyala self-assigned this Jan 29, 2024
@RajeevPentyala
Copy link
Collaborator

@iamaninda93 If you prefer not to use the 'ALM Accelerator' versioning pattern, you can set the variable 'skipSolutionVersioning' to true in the Deployment pipelines. Please refer the related issue here : #7105

@iamaninda93
Copy link
Author

iamaninda93 commented Jan 30, 2024

@RajeevPentyala The below screenshot is the Coe alm accelerator templates folder. Can you tell in which of the yml file I need to set the variable 'skipSolutionVersioning' to true ?
MicrosoftTeams-image (3)

@RajeevPentyala
Copy link
Collaborator

@iamaninda93 You don't need to change the yml files. Add a 'skipSolutionVersioning' variable under Pipelines > Library > alm-accelerator-variable-group as shown below.

image

@iamaninda93
Copy link
Author

@RajeevPentyala I have added"SkipSolutionVersioning" to true in the varable group. Apart from that in which yml file the version format needs to be added?

Desired Version format: YYYYMMDD.revision

Cuurent YML file:
MicrosoftTeams-image (4)

@iamaninda93
Copy link
Author

iamaninda93 commented Jan 31, 2024 via email

@RajeevPentyala
Copy link
Collaborator

@iamaninda93 Please note that ALM Accelerator exhibits two behaviors when it comes to solution versioning.

  • If SkipSolutionVersioning is set to false, which is the default behavior, it assigns the version to an auto-generated build number. The corresponding logic can be found here: ..\Pipelines\Templates\build-Solution.yml > 'Update Solution XML with Build Number' task.
  • If SkipSolutionVersioning is set to true, 'ALM Accelerator' will not assign any version number, and it will consider whatever version number is set in the maker environment.

@mikefactorial
Copy link
Collaborator

@iamaninda93
Copy link
Author

@mikefactorial
I have taken below steps. Still getting the default version number. My desired version number is "20240112.1", "20240112.2"
What I am getting is "1.0.$(Date:yyyyMMdd)$(Rev:.r)". I dont want the Dev environment version number in QA or in prod. Every deployment to Qa/prod will increase version number of QA and Prod.

Step 1 :
build-solution-pack-pre-hook.yml-----

steps:

  • script: echo Build Solution Pack Pre Hook
    displayName: 'Build Solution Pack Pre Hook'
    enabled: True

CUSTOMIZED: Using below template to customize solution version number.

  • template: CustomTemplates/custom-solution-version-number.yml

Step 2: custom-solution-version-number.yml

steps:

  • task: PowerShell@2
    displayName: 'Set Solution Version'
    inputs:
    targetType: 'inline'
    script: |
    $date = Get-Date -Format yyyyMMdd
    $revision = $env:BUILD_BUILDNUMBER
    $version = "$date.$revision"
    Write-Host "##vso[task.setvariable variable=SolutionVersion]$version"

@mikefactorial
Copy link
Collaborator

mikefactorial commented Feb 6, 2024

@iamaninda93 thanks for the detailed response. Looks like you're pretty close. You'll just want to inject the version number you are creating in custom-solution-version-number.yml into the solution.xml similar to how we are doing it in the powershell script @RajeevPentyala mentioned above.

See here
https://github.com/microsoft/coe-alm-accelerator-templates/blob/d7c09997b129e4f0811e98a39e6ad2aa1724816a/Pipelines/Templates/build-Solution.yml#L91

and here
https://github.com/microsoft/coe-alm-accelerator-templates/blob/d7c09997b129e4f0811e98a39e6ad2aa1724816a/PowerShell/build-deploy-solution-functions.ps1#L314

Something like the following. NOTE: This isn't tested just a sample

task: PowerShell@2
displayName: 'Set Solution Version'
inputs:
targetType: 'inline'
script: |
. "$env:POWERSHELLPATH/load-save-pipeline-parameters.ps1"
$parameters = Read-Pipeline-Parameters "$(Agent.BuildDirectory)\build-pipeline-parameters.json"
$solutionXMLPath = "$(Build.SourcesDirectory)\$(RepoName)\$parameters.solutionName\SolutionPackage\src\Other\Solution.xml"
$date = Get-Date -Format yyyyMMdd
$revision = $env:BUILD_BUILDNUMBER
$version = "$date.$revision"
[xml]$xmlDoc = Get-Content -Path $solutionXMLPath
$xmlDoc.ImportExportXml.SolutionManifest.Version ="$version"
$xmlDoc.save("$solutionXMLPath")

@iamaninda93
Copy link
Author

@mikefactorial

Here is the code given below. While running the pipeline its throwing error.Can you have a look?
MicrosoftTeams-image (5)

steps:

  • task: PowerShell@2
    displayName: 'Set Solution Version'
    inputs:
    targetType: 'inline'
    script: |
    . "$env:POWERSHELLPATH/load-save-pipeline-parameters.ps1"
    $parameters = Read-Pipeline-Parameters "$(Agent.BuildDirectory)\build-pipeline-parameters.json"
    $solutionXMLPath = "$(Build.SourcesDirectory)$(RepoName)$parameters.solutionName\SolutionPackage\src\Other\Solution.xml"
    $date = Get-Date -Format yyyyMMdd
    $revision = $env:BUILD_BUILDNUMBER
    $version = "$date.$revision"
    [xml]$xmlDoc = Get-Content -Path $solutionXMLPath
    $xmlDoc.ImportExportXml.SolutionManifest.Version ="$version"
    $xmlDoc.save("$solutionXMLPath")
    Write-Host "##vso[task.setvariable variable=SolutionVersion]$version"

@mikefactorial
Copy link
Collaborator

@iamaninda93 try replacing

$solutionXMLPath = "$(Build.SourcesDirectory)\$(RepoName)\$parameters.solutionName\SolutionPackage\src\Other\Solution.xml"

with

$solutionName = $parameters.solutionName
$solutionXMLPath = "$(Build.SourcesDirectory)\$(RepoName)\$solutionName\SolutionPackage\src\Other\Solution.xml"

@mikefactorial
Copy link
Collaborator

Closing this out since there hasn't been a response in a while. Please let us know if you are still having this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alm-accelerator ALM Accelerator Components and Apps enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

3 participants