Hi @Abhishek Kumar ,
Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.
It sounds like you're looking to replace your Personal Access Token (PAT) with a System Access Token in your Azure DevOps pipeline task. Here’s how you can do it:
When using the Azure CLI task (AzureCLI@2) in your pipeline, you can make use of the System.AccessToken which is an automatically generated token available during pipeline execution. This token has the permissions of the build service identity.
Here’s how you can push your updates to a central repo using the System.AccessToken instead of a PAT:
- Check Your Pipeline Configuration: Ensure that your pipeline’s YAML file is set up to include the
System.AccessToken. Thecheckoutstep should also be configured correctly. - Update Your Script: Replace the part of your inline bash script where you're using
AZURE_DEVOPS_EXT_PATto authenticate with Git. Instead of using the PAT, set the authentication to use theSystem.AccessTokenlike so:# Clone your repository (adjust the URL as needed) git clone https://dev.azure.com/{organization}/{project}/_git/{repository} # Navigate into your repo cd {repository} # Configure Git to use the System.AccessToken for authentication git config --global credential.helper manager-core echo "https://$(System.AccessToken):@dev.azure.com" > ~/.git-credentials # Now you can push your changes git add . git commit -m "Your commit message" git push - Permissions: Make sure that the
System.AccessTokenhas the necessary permissions to access the repository. You might have to adjust pipeline permissions in Azure DevOps under Project settings > Repositories > [repository] > Security. - Testing: After making these changes, run your pipeline to check if the updates are pushed successfully.
By doing this, you avoid the need for a PAT and make use of the built-in capabilities of Azure DevOps pipelines.
I hope this helps! If you have more questions or run into issues, feel free to ask.
Reference Documentation:
Let me know if you need further assistance!
Note: This content was drafted with the help of an AI system.