0
votes

I have an old settings.xml in the Azure devops agent's .m2 directory. I want to override it with new settings.xml through task group, but should not do any changes with the old settings.xml file. Because if it is worked, then we will update the old xml file.

How could we achieve the same using Azure Devops task group?

2
Hi @Kivi. Is there any update about this ticket? Feel free to let me know if the answer could give you some help. Just a remind of this.Kevin Lu-MSFT
I have placed settings.xml in Azure Devops agent as per the requirement change and I configured in the maven task in task group and it worked fine. Thanks for the inputs provided.Kivi
Glad to know that it could work fine. You could try my answer, it could be applied to more situations(e.g. microsoft-hosted agents). If it could work, you may consider accepting it as answer. This will be helpful.Kevin Lu-MSFT

2 Answers

1
votes

How could we achieve the same using Azure Devops task group?

I suggest that you could save the settings.xml file in Pipelines -> Library -> Secure files.

enter image description here

In Task Group, you could add Download secure file task and Maven task.

Download secure file task: Set the Reference Name and select the file

enter image description here

Maven task: Set the reference Settings.xml path: -s $(mvnSettings.secureFilePath)

enter image description here

Then you could create a task group.

Note: You need to set the paramter for the task group:

Default value: $(Agent.TempDirectory)/settings.xml

enter image description here

In this case, the old settings.xml will not be changed. When you reference this task group, it will download the new settings.xml in the secure file and reference the new settings.xml file in the maven task.

If you do not reference this task group, it can still use the old settings.xml file.

0
votes

If you use maven task to build your project and authenticate with settings.xml, you could use this task twice, the 1st task uses the old settings.xml, and the 2nd task uses the new settings.xml.

In addition, you could specify the control condition to run this 2nd task only when a previous task has failed, as below. So the 2nd task will run only when the 1st maven task fails. See: Specify conditions for more details. enter image description here