git - 批处理文件中的 Git 命令通过 VSTS 运行并引发错误
问题描述
我已将远程 GitHub 存储库克隆到我的构建服务器中。VSTS 中的构建定义生成了一个文件作为构建工件。我通过 VSTS 中的 powershell 脚本任务将该文件复制到构建服务器中的本地 github 存储库中。我想运行 Git 命令将这个新的构建工件文件从本地 github 存储库推送到远程 GitHub 存储库。我在构建服务器上存储了带有 Git 命令的批处理文件。当构建在 VSTS 上运行时,我尝试通过“命令行脚本”VSTS 任务调用驻留在构建服务器中的批处理文件。
命令行脚本:
cd "batch file path"
GitCommands.bat
现在我不断收到与批处理文件中的 git 命令相关的错误。下面是一个例子。
注意:我正在尝试使用批处理文件中的 git 命令将单个文件直接推送到 github 存储库。
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)?
批处理文件内容:
*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*
解决方案
您可以使用PowerShell 任务来替换命令行任务。PowerShell 脚本应该是:
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:password@github.com/username/reponame master
然后你应该提交并将新添加的文件成功推送到 github repo。
注意:将更改推送到 github 时,您需要提供凭据(用户名和密码)。
推荐阅读
- corda - 使用 network-bootstrapper 生成节点信息需要带有 devMode=false 的证书
- php - 由于 .htaccess,php curl 出现 301 错误
- ios - Stripe STPAddCardViewController 导航栏未显示
- java - 如何从字符串中提取表情符号和字母字符
- html - 当我尝试将数据从父组件传递到子组件时,数据显示为未定义
- node.js - node js升级6到8版本报错
- alexa - Alexa Skill ki 手动输入
- java - 需要帮助列出基于用户输入的字符频率
- wordpress - Hawkhost 重定向到 Wordpress
- class - 如何在本机反应中包含来自另一个文件的组件视图?