Kriem
Kriem

Reputation: 8705

How do I push a Team Services git repository after build to an external git repository?

Push to a different repository then the origin

I have a Team Services git repository which I successfully clone and build when releasing my project. After the build, I would like to push my build artifact to a different git repository location.

git commands via the command line tasks

I'm able to initialize a git repo from the build artifact via a command line task (git init), but Team Service won't allow for fetching, pulling and pushing via the command line task.

External git endpoint

So, the documentation says I need to use the external git endpoint. But I don't see how I can use this endpoint to push my build to.

Am I missing something?

Upvotes: 2

Views: 849

Answers (1)

Eddie Chen - MSFT
Eddie Chen - MSFT

Reputation: 29968

I did a quick test with this but didn't see any issue. The git repository can be pushed to external remote repository successfully.

To reduce the steps in the definition, I created a batch script to perform the git action and upload the batch script into VSTS Source Control:

git init

git add .

git commit -m "VSTSBuildArtifacts"

git remote add origin https://xxxxxxxxx

git pull origin master

git push origin master

Following is my steps(I skipped the build steps, just copied some files as the build output files):

  1. Create an empty build definition.
  2. Add "Copy Files" task and configure it to copy some files to "$(Build.ArtifactStagingDirectory)" folder. enter image description here
  3. Add a "Batch Script" task and set the "Path" to the batch script file and "Working folder" to "$(Build.ArtifactStagingDirectory)". enter image description here
  4. Save the definition and queue a build.enter image description here

Upvotes: 1

Related Questions