1

I have cloned remote GitHub repository into my Build Server. A build definition in VSTS generated a file as build artifact. I copy that file into local github repository in build server through a powershell script task in VSTS. I want to run Git commands to push this new build artifact file from local github repository to remote GitHub repository. I have stored batch file with Git commands on build server. When a build runs on VSTS, I try to invoke batch file residing in build server through a "Command Line Script" VSTS task.

Command Line Script:

cd "batch file path"
GitCommands.bat

Now I keep getting errors related to git commands in batch file. Below is an example.

Note: I am trying to push a single file directly to github repository using git commands in batch file.

2018-08-30T20:17:07.9089221Z On branch master
2018-08-30T20:17:07.9090417Z Your branch is up to date with 'origin/master'.
2018-08-30T20:17:07.9166091Z 
2018-08-30T20:17:07.9180427Z Untracked files:
2018-08-30T20:17:07.9205244Z   (use "git add <file>..." to include in what will be committed)
2018-08-30T20:17:07.9224271Z 
2018-08-30T20:17:07.9298112Z    filename.ipa
2018-08-30T20:17:07.9316134Z 
2018-08-30T20:17:07.9457726Z nothing added to commit but untracked files present (use "git add" to track)
2018-08-30T20:17:10.4572412Z fatal: Unable to write new index file
2018-08-30T20:17:10.4614209Z file added
2018-08-30T20:17:10.5106172Z On branch master
2018-08-30T20:17:10.5107096Z Your branch is up to date with 'origin/master'.
2018-08-30T20:17:10.5131465Z 
2018-08-30T20:17:10.5145982Z Untracked files:
2018-08-30T20:17:10.5184825Z    filename.ipa
2018-08-30T20:17:10.5204032Z 
2018-08-30T20:17:10.5280428Z nothing added to commit but untracked files present
2018-08-30T20:17:38.9087093Z Terminate batch job (Y/N)? 

Batch file content:

*cd to github loval repository

git status

git add .

echo file added

git commit -m "Adding ipa file to the repository through VSTS automated build"

git push origin master*
1
  • It's due to some lock here the solution is Commented Aug 31, 2018 at 2:11

1 Answer 1

0

You can use a PowerShell task to replace the Command Line task. The PowerShell script should be:

cd \path\to\local\github\repo
git status
git add .
echo "file added"
git commit -m "Adding ipa file to the repository through VSTS automated build"
git push https://username:[email protected]/username/reponame master

Then you should commit and push the new added file successful to github repo.

Note: You need to provide credential (username and password) when pushing changes to github.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.