2016-11-30 2 views
0

VSTSでビルド定義を作成しました。私は "ソースを取得"の直後にpowerShellスクリプトを実行したい。「リソースを取得する」がブランチとデタッチされていないリポジトリを作成するとき、VSTSビルド定義はなぜですか?

私はいくつかの枝が作成されていることを確認することができ、「取得元」フェーズ中:次に

Checking out files: 100% (16011/16011), done. 
Note: checking out '2c5ac1a6dab64603656be2610dc5c2c627b916d4'. 
You are in 'detached HEAD' state. You can look around, make experimental 
changes and commit them, and you can discard any commits you make in this 
state without impacting any branches by performing another checkout. 
If you want to create a new branch to retain commits you create, you may 
do so (now or later) by using -b with the checkout command again. Example: 
git checkout -b <new-branch-name> 
HEAD is now at 2c5ac1a... "Merge develop to master" 

それは次のとおりです。そして、それは、最新のが切り離さHEADにコミットチェックアウト

From https://domain.visualstudio.com/_git/main 
* [new branch]  develop   -> origin/develop 
* [new branch]  master   -> origin/master 
....... 

を私のpowerShellスクリプトの時間は、私は発行時にブランチが作成されていません

"git branch -v" 

私はこれを参照してください:枝の残りの部分は作成され

2016-11-30T10:42:26.6370529Z * (HEAD detached at 41e7eb4) 41e7eb4 first commit 
2016-11-30T10:42:27.0110730Z ##[error]Previous HEAD position was 41e7eb4... first commit 
2016-11-30T10:42:27.7881014Z ##[error]Switched to a new branch 'develop' 
2016-11-30T10:42:27.9670995Z ##[error] * [new branch]  test -> test 
2016-11-30T10:42:28.1945915Z ##[error]Process completed with exit code 0 and  had 3 error(s) written to the error stream. 
2016-11-30T10:42:28.1955965Z ##[section]Finishing: PowerShell Script 

:私はチェックアウトを作成したり、私のPowerShellスクリプトで新しいブランチを作成しようとすると、

2016-11-30T10:42:26.6370529Z * (HEAD detached at 41e7eb4) 41e7eb4 first commit 

はまた、彼らは「赤線(エラー)」として表示されます「リソースを取得する」フェーズ中に?なぜ私は分離ヘッドを持っていますか?そしてなぜ私は支店をチェックアウト/作成できないのですか?

おかげで、


--UPDATE-- 私のビルドはブランチを作成し、リモートに直接それらをプッシュすることができます。ビルドサービスアカウントに「貢献」と「ブランチ作成」アクセスを許可する必要がありました。しかし、ブランチとコミットは実際に作成され、リモートにプッシュされますが、私はまだ自分のビルドを赤くするエラーを取得します。

私のスクリプトは以下になります(それがインラインPowerShellスクリプトです)(私はそれをsimpliefied):

git branch -a -v 
git fetch --all 
git branch -a 
git checkout -b master remotes/origin/master 

git checkout -b testBranch 
Out-File -FilePath auto-file.txt 
git add . 
git commit -m "just created an auto commit" 
git push -u origin testBranch 

そしてここでは、対応するログです:

2016-12-09T08:05:14.9777018Z ##[section]Starting: Build 
2016-12-09T08:05:14.9897018Z Current agent version: '2.109.1' 
2016-12-09T08:05:15.6197698Z Downloading task: PowerShell 
2016-12-09T08:05:16.6935776Z ##[section]Starting: Get Sources 
2016-12-09T08:05:16.7755760Z Syncing repository: main (TfsGit) 
2016-12-09T08:05:16.7806005Z Prepending Path environment variable with directory containing 'git.exe'. 
2016-12-09T08:05:16.7925998Z ##[command]git version 
2016-12-09T08:05:16.9935896Z ##[command]git init "C:\a\1\s" 
2016-12-09T08:05:17.0525625Z Initialized empty Git repository in C:/a/1/s/.git/ 
2016-12-09T08:05:17.0565864Z ##[command]git remote add origin https://domain .visualstudio.com/MyFirstProject/_git/main 
2016-12-09T08:05:17.0795632Z ##[command]git config gc.auto 0 
2016-12-09T08:05:17.1035633Z ##[command]git config --get-all http.https://domain .visualstudio.com/MyFirstProject/_git/main.extraheader 
2016-12-09T08:05:17.1337092Z ##[command]git config --get-all http.proxy 
2016-12-09T08:05:17.1597344Z ##[command]git -c http.extraheader="AUTHORIZATION: bearer ********" fetch --tags --prune --progress origin 
2016-12-09T08:05:18.1333289Z remote: 
2016-12-09T08:05:18.1343246Z remote:     vSTs   
2016-12-09T08:05:18.1343246Z remote:     vSTSVSTSv   
2016-12-09T08:05:18.1343246Z remote:    vSTSVSTSVST   
2016-12-09T08:05:18.1343246Z remote: VSTS   vSTSVSTSVSTSV   
2016-12-09T08:05:18.1343246Z remote: VSTSVS  vSTSVSTSV STSVS   
2016-12-09T08:05:18.1343246Z remote: VSTSVSTSvsTSVSTSVS TSVST   
2016-12-09T08:05:18.1343246Z remote: VS tSVSTSVSTSv  STSVS   
2016-12-09T08:05:18.1343246Z remote: VS tSVSTSVST  SVSTS   
2016-12-09T08:05:18.1343246Z remote: VS tSVSTSVSTSVSts VSTSV   
2016-12-09T08:05:18.1343246Z remote: VSTSVST SVSTSVSTs VSTSV   
2016-12-09T08:05:18.1343246Z remote: VSTSv  STSVSTSVSTSVS   
2016-12-09T08:05:18.1343246Z remote:    VSTSVSTSVST   
2016-12-09T08:05:18.1343246Z remote:     VSTSVSTs   
2016-12-09T08:05:18.1343246Z remote:     VSTs (TM)   
2016-12-09T08:05:18.1343246Z remote: 
2016-12-09T08:05:18.1343246Z remote: Microsoft (R) Visual Studio (R) Team Services   
2016-12-09T08:05:18.1343246Z remote: 
2016-12-09T08:05:18.2981730Z From https://domain .visualstudio.com/MyFirstProject/_git/main 
2016-12-09T08:05:18.2981730Z * [new branch]  develop -> origin/develop 
2016-12-09T08:05:18.2981730Z * [new branch]  master  -> origin/master 
2016-12-09T08:05:18.3001809Z ##[command]git checkout --progress --force 7af1f2611269277da2c520b84148844e650acc4f 
2016-12-09T08:05:18.3241819Z Note: checking out '7af1f2611269277da2c520b84148844e650acc4f'. 
2016-12-09T08:05:18.3241819Z 
2016-12-09T08:05:18.3241819Z You are in 'detached HEAD' state. You can look around, make experimental 
2016-12-09T08:05:18.3241819Z changes and commit them, and you can discard any commits you make in this 
2016-12-09T08:05:18.3241819Z state without impacting any branches by performing another checkout. 
2016-12-09T08:05:18.3241819Z 
2016-12-09T08:05:18.3241819Z If you want to create a new branch to retain commits you create, you may 
2016-12-09T08:05:18.3241819Z do so (now or later) by using -b with the checkout command again. Example: 
2016-12-09T08:05:18.3241819Z 
2016-12-09T08:05:18.3241819Z git checkout -b <new-branch-name> 
2016-12-09T08:05:18.3241819Z 
2016-12-09T08:05:18.3241819Z HEAD is now at 7af1f26... try to fix cachedconfig issue 
2016-12-09T08:05:18.3261731Z ##[command]git config http.https://domain .visualstudio.com/MyFirstProject/_git/main.extraheader "AUTHORIZATION: bearer ********" 
2016-12-09T08:05:18.3491840Z ##[section]Finishing: Get Sources 
2016-12-09T08:05:18.3511738Z ##[section]Starting: PowerShell Script 
2016-12-09T08:05:18.3811752Z ============================================================================== 
2016-12-09T08:05:18.3811752Z Task   : PowerShell 
2016-12-09T08:05:18.3811752Z Description : Run a PowerShell script 
2016-12-09T08:05:18.3821755Z Version  : 1.2.1 
2016-12-09T08:05:18.3821755Z Author  : Microsoft Corporation 
2016-12-09T08:05:18.3821755Z Help   : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736) 
2016-12-09T08:05:18.3821755Z ============================================================================== 
2016-12-09T08:05:18.4611894Z ##[command]. 'C:\Users\buildguest\AppData\Local\Temp\928a835e-178f-40c1-8ba5-61da96fc8fc7.ps1' 
2016-12-09T08:05:19.1941140Z * (HEAD detached at 7af1f26) 7af1f26 try to fix cachedconfig issue 
2016-12-09T08:05:19.2081155Z remotes/origin/develop 7af1f26 try to fix cachedconfig issue 
2016-12-09T08:05:19.2090954Z remotes/origin/master 41e7eb4 first commit 
2016-12-09T08:05:19.2090954Z Fetching origin 
2016-12-09T08:05:19.5648482Z * (HEAD detached at 7af1f26) 
2016-12-09T08:05:19.5648482Z remotes/origin/develop 
2016-12-09T08:05:19.5648482Z remotes/origin/master 
2016-12-09T08:05:19.5909153Z ##[error]Previous HEAD position was 7af1f26... try to fix cachedconfig issue 
Switched to a new branch 'master' 

2016-12-09T08:05:19.5939144Z Branch master set up to track remote branch master from origin. 
2016-12-09T08:05:19.6609174Z ##[error]Switched to a new branch 'testBranch' 

2016-12-09T08:05:19.6609174Z [testBranch 847ac8b] just created an auto commit 
2016-12-09T08:05:19.6619147Z Committer: buildguest <buildguest> 
2016-12-09T08:05:19.6619147Z Your name and email address were configured automatically based 
2016-12-09T08:05:19.6619147Z on your username and hostname. Please check that they are accurate. 
2016-12-09T08:05:19.6619147Z You can suppress this message by setting them explicitly. Run the 
2016-12-09T08:05:19.6619147Z following command and follow the instructions in your editor to edit 
2016-12-09T08:05:19.6619147Z your configuration file: 
2016-12-09T08:05:19.6619147Z 
2016-12-09T08:05:19.6619147Z  git config --global --edit 
2016-12-09T08:05:19.6619147Z 
2016-12-09T08:05:19.6619147Z After doing this, you may fix the identity used for this commit with: 
2016-12-09T08:05:19.6619147Z 
2016-12-09T08:05:19.6619147Z  git commit --amend --reset-author 
2016-12-09T08:05:19.6619147Z 
2016-12-09T08:05:19.6619147Z 1 file changed, 1 insertion(+) 
2016-12-09T08:05:19.6619147Z create mode 100644 auto-file.txt 
2016-12-09T08:05:20.4268088Z ##[error]To https://domain .visualstudio.com/MyFirstProject/_git/main 

2016-12-09T08:05:20.4268088Z Branch testBranch set up to track remote branch testBranch from origin. 
2016-12-09T08:05:20.6018082Z ##[error] * [new branch]  testBranch -> testBranch 

2016-12-09T08:05:20.8482358Z ##[error]Process completed with exit code 0 and had 4 error(s) written to the error stream. 
2016-12-09T08:05:20.8492359Z ##[section]Finishing: PowerShell Script 
2016-12-09T08:05:20.8502361Z ##[section]Starting: Post Job Cleanup 
2016-12-09T08:05:20.8562360Z Cleaning any cached credential from repository: main (Git) 
2016-12-09T08:05:20.8602360Z ##[command]git config --unset-all http.https://domain .visualstudio.com/MyFirstProject/_git/main.extraheader 
2016-12-09T08:05:20.8872360Z ##[command]git remote set-url origin https://domain .visualstudio.com/MyFirstProject/_git/main 
2016-12-09T08:05:20.9142348Z ##[command]git remote set-url --push origin https://domain .visualstudio.com/MyFirstProject/_git/main 
2016-12-09T08:05:20.9342662Z ##[section]Finishing: Post Job Cleanup 
2016-12-09T08:05:20.9352355Z ##[section]Finishing: Build 

答えて

0

問題は、WindowsとPowerShellのgitが標準の入力/出力/エラーマッピングに問題があり、powershellが情報をエラーとして解釈するために発生しました。
バッチファイルでpowershellスクリプトを置き換えて、対応するタスクを使用すると、問題が解決しました。

+0

ブランチを作成してリポジトリに寄付する権利を「ビルドサービスアカウント」に与える必要がありました。 – forti

+0

添付のモードに戻るには特別なコマンドを実行する必要がありましたか? – baywet

+0

ローカルのマスターブランチをチェックアウトしています:git checkout -b master remotes/origin/master – forti

関連する問題