Search code examples
azure-devopsazure-pipelinestfvc

push code back to TFVC repository on Azure Devops


I am trying to push back code to a TFVC through a Azure Devops pipeline but I cannot make it work. I am using a powershell task and tf commands to automatically commit changes through a processing that happens on a pipeline. The output of this processing should be pushed back on the working TFVC repository.

First I create a sample file on the Pipeline.Workspace on sources folder.

Command line step.

echo "content 1 2 3" >  $(Pipeline.Workspace)/s/file_created_by_pipeline.txt
ls $(Pipeline.Workspace)/s

Then I try to commit changes back on repository.

Powershell task:

cd $(Pipeline.Workspace)/s
tf add .*.txt /resursive; 
tf checkin .*.txt /comment "added new files" /recursive  /force

Issue:

No changes were matched by any arguments

During the run of the pipeline I have also to provide codes based on the OAuth 2.0 Device Flow authentication

Also when I set the TF_BYPASS_BROWSER_LOGIN=true variable on the pipeline I get

Default credentials are unavailable because no Kerberos ticket or other authentication token is available.

My goal is to push changes back on the working repository which is the source of code for this pipeline. Also I need to bypass the Oath authentication. I have already selected the allow scripts to access the OAuth token on the agent job.


Solution

  • Have you tried my TFVC extensions? They were made for this exact purpose.

    enter image description here

    Alternatively, you can try using the OAuth token of the pipeline to check in:

    & tf vc checkin .*.txt /comment "added new files" /recursive /force
       /loginType:OAuth /login:.,$env:SYSTEM_ACCESSTOKEN
    

    Make sure to configure the pipeline so it can access the token:

    enter image description here

    If needed add the access token to the PowerShell Task's environment variable section:

    enter image description here