Hi champs ,
I'm implementing CI\CD in AX2012 using Azure DevOps and my build succeeded and generated an Artifact file (which is .AX model)
however my release pipeline has following function to install the .AXmodel file which is a build artifact
function Install-Model($folder, $file)
{
if($file -ne $null -and $folder -ne $null)
{
$newModel = $file.Replace('.axmodel','')
$file = join-path $folder $file
if((test-path $file) -eq $true)
{
$exp = ''
$modelName = Get-ModelName($file)
Write-Host $modelName
$instVer = Get-InstalledVersion($modelName)
$newVer = Get-FileVersion($file)
$extraArguments = ''
Write-InfoLog ("code reached before if and extraargs value here is {0}" -f $extraArguments)
if($importOverrideParams -ne $null)
{
if($importOverrideParams.Contains($modelName))
{
$extraArguments = $importOverrideParams.Get_Item($modelName)
Write-InfoLog ("code reached if and extarguments value here is {0}" -f $extraArguments)
}
}
if ($instVer -ne "")
{
if ($newVer -ne $instVer)
{
Write-InfoLog ("Replacing model {0}, old version {1} with new version {2} and extra args {3}." -f $newModel, $instVer, $newVer, $extraArguments)
$exp = 'Install-AXModel {0} -File "{1}" -replace "{4}" -NoPrompt -Server "{2}" -Database "{3}" ' -f $extraArguments, $file, $sqlServer, $sqlModelDatabase, $modelName
write-host $exp
}
else
{
Write-InfoLog ("Skipping model {0}, installed version is identical {1}" -f $newModel, $newVer)
}
}
else
{
Write-InfoLog ("Installing model {0}, version {1}, extra args {2}." -f $newModel, $newVer, $extraArguments)
$exp = 'Install-AXModel {0} -File "{1}" -NoPrompt -Server "{2}" -Database "{3}" ' -f $extraArguments, $file, $sqlServer, $sqlModelDatabase
}
if ($exp -ne '')
{
Invoke-Expression $exp
}
}
}
}
However I see the below error after running this script , can you please post your thoughts on the same .
2020-07-09T17:51:38.0026450Z U******e
2020-07-09T17:51:38.6588855Z 7/9/2020 7:51:38 PM - code reached before if and extraargs value here is
2020-07-09T17:51:38.6588855Z 7/9/2020 7:51:38 PM - Replacing model U*****e, old version 6.3.20200604.2 with new version 6.3.20200629.1 and extra args .
2020-07-09T17:51:38.6588855Z Install-AXModel -File "C:\Vsts_Agent\_work\r2\a\LM Build.Stream1\drop\Application\Appl\U******e.axmodel" -replace "U******e" -NoPrompt -Server "SR60212\UATST10" -Database "UATST2_AxDB_model"
2020-07-09T17:52:06.5192900Z ##[error]Install-AXModel : The pipeline has been stopped.
At line:1 char:1
+ Install-AXModel -File "C:\Vsts_Agent\_work\r2\a\LM Build.Stream1\drop\Applicati ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Install-AXModel], PipelineStoppedException
+ FullyQualifiedErrorId : One or more conflicting model elements already exists in an
installed model.,Microsoft.Dynamics.AX.Framework.Tools.ModelManagement.PowerShell.InstallAXModelCommand
For you info : there is a existing model with the same name however with a different version and there might be some conflicting elements however I'm assuming Replace flag should replace it , let me know if -conflict push will work here
Thanks and Regards,
Anirudh Parasaram