C:\Multi-Runner>gitlab-ci-multi-runner-windows-amd64.exe register Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci): URL Please enter the gitlab-ci token for this runner: token Please enter the gitlab-ci description for this runner: [DESKTOP-2P9GHDD]: xishuai-ci Please enter the gitlab-ci tags for this runner (comma separated): dev Registering runner... succeeded runner=avuSXASJ Please enter the executor: docker-ssh, parallels, shell, ssh, virtualbox, docker+machine, docker-ssh+machine, docker: shell Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
gitlab-ci-multi-runner 1.1.3 (a470667) Using Shell executor... Running on DESKTOP-2P9GHDD... Cloning repository... Cloning into 'C:/Multi-Runner/builds/500c7a25/0/dev/CNBlogsCI-Sample'... fatal: unable to access 'https://gitlab-ci-token:xxxxxx@gitlab.com/dev/CNBlogsCI-Sample.git/': error setting certificate verify locations: CAfile: C:\Multi-Runner\builds\500c7a25\0\dev\CNBlogsCI-Sample.tmp\GIT_SSL_CAINFO CApath: none The system cannot find the path specified. Checking out ac05d090 as master... fatal: Not a git repository (or any of the parent directories): .git
gitlab-ci-multi-runner 1.1.3 (a470667) Using Shell executor... At C:\Users\xishuai\AppData\Local\Temp\build_script140243225\script.ps1:132 char:105 + ... 0.0\packages\NuGet.CommandLine.2.8.5\tools\NuGet.exe" restore "src/CN ... + ~~~~~~~ Unexpected token 'restore' in expression or statement. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedErrorId : UnexpectedToken
ERROR: Build failed: exit status 1
从错误信息中可以看到,没有识别restore命令,啥意思?这个问题又搞了我好久,Google Unexpected token 'restore' in expression or statement. 关键字,毛都搜不到,没办法,后来只能更换关键字搜,但搜到的信息凤毛麟角,后来参考搜来的资料,将.gitlab-ci.yml改为:
gitlab-ci-multi-runner 1.1.3 (a470667) Using Shell executor... Running on DESKTOP-2P9GHDD... Fetching changes... HEAD is now at 3926803 Update .gitlab-ci.yml From https://gitlab.com/dev/CNBlogsCI-Sample 3926803..d8f10a7 master -> origin/master Checking out d8f10a7c as master... Previous HEAD position was 3926803... Update .gitlab-ci.yml HEAD is now at d8f10a7... Update .gitlab-ci.yml $ ls
Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 5/4/2016 02:45 PM src -a---- 5/4/2016 02:45 PM 89 .gitignore -a---- 5/4/2016 02:49 PM 527 .gitlab-ci.yml $ echo "Restoring NuGet Packages..." Restoring NuGet Packages... $ call "%VS140COMNTOOLS%\vsvars32.bat" call : The term 'call' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Users\xishuai\AppData\Local\Temp\build_script250102679\script.ps1:132 char:3 + call "%VS140COMNTOOLS%\vsvars32.bat" + ~~~~ + CategoryInfo : ObjectNotFound: (call:String) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : CommandNotFoundException
ERROR: Build failed: exit status 1
也是毫无头绪的错误,这么办呢?后来想想nuget restore始终不成功,能不能换个命令呢?突然想到了 ASP.NET 5,还原程序包使用的是dnu restore命令,那就尝试下吧,将解决方案中的项目删掉,然后添加 ASP.NET 5 项目,.gitlab-ci.yml改为:
1 2 3 4
before_script: - echo "Restoring NuGet Packages..." - dnvm use 1.0.0-beta5 -r coreclr -a x64 - dnu restore
Running on DESKTOP-2P9GHDD... Fetching changes... HEAD is now at 33436d8 test commit From https://gitlab.com/dev/CNBlogsCI-Sample 33436d8..c80b2d5 master -> origin/master Checking out c80b2d5d as master... Previous HEAD position was 33436d8... test commit HEAD is now at c80b2d5... test commit $ echo "Release build..." Release build... $ dnvm use 1.0.0-beta5 -r coreclr -a x64 Adding C:\Users\xishuai\.dnx\runtimes\dnx-coreclr-win-x64.1.0.0-beta5\bin to process PATH $ dnu restore Microsoft .NET Development Utility CoreCLR-x64-1.0.0-beta5-12103
Restoring packages for C:\Multi-Runner\builds\5ae63365\0\dev\CNBlogsCI-Sample\src\CNBlogsCI-Sample.ClassLibrary\project.json GET https://www.nuget.org/api/v2/ OK https://www.nuget.org/api/v2/ 5524ms GET http://nuget.cnitblog.com/nuget/Default/ OK http://nuget.cnitblog.com/nuget/Default/ 2406ms GET https://www.myget.org/F/aspnetvnext/api/v2/ OK https://www.myget.org/F/aspnetvnext/api/v2/ 5225ms CACHE https://www.nuget.org/api/v2/ GET https://www.myget.org/F/aspnetmaster/api/v3/index.json OK https://www.myget.org/F/aspnetmaster/api/v3/index.json 2938ms GET https://www.myget.org/F/xunit/api/v3/index.json OK https://www.myget.org/F/xunit/api/v3/index.json 1976ms Writing lock file C:\Multi-Runner\builds\5ae63365\0\dev\CNBlogsCI-Sample\src\CNBlogsCI-Sample.ClassLibrary\project.lock.json Restore complete, 18775ms elapsed
Build succeeded
虽然 ASP.NET 5 还原程序包成功了,但依旧解决不了问题啊,因为必须得解决nuget restore的问题,因为很多项目都没用 ASP.NET 5,怎么办呢?又回到了出发点,问题能磨死人啊,过程就不叙述了,后来无意间将.gitlab-ci.yml改为:
gitlab-ci-multi-runner 1.1.3 (a470667) Using Shell executor... Running on DESKTOP-2P9GHDD... Fetching changes... Removing src/ClassLibrary1/bin/ Removing src/ClassLibrary1/obj/ HEAD is now at 191e7e0 test commit From https://gitlab.com/dev/CNBlogsCI-Sample 191e7e0..feebdef master -> origin/master Checking out feebdefb as master... Previous HEAD position was 191e7e0... test commit HEAD is now at feebdef... test commit $ echo "Restoring NuGet Packages..." Restoring NuGet Packages... $ C:\Program Files (x86)\NuGet\nuget.exe restore src/CNBlogsCI-Sample.sln x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Users\xishuai\AppData\Local\Temp\build_script166211738\script.ps1:128 char:21 + C:\Program Files (x86)\NuGet\nuget.exe restore src/CNBlogsCI-Sample ... + ~~~ + CategoryInfo : ObjectNotFound: (x86:String) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : CommandNotFoundException
gitlab-ci-multi-runner 1.1.3 (a470667) Using Shell executor... Running on DESKTOP-2P9GHDD... Fetching changes... HEAD is now at 1ac80d7 test commit From https://gitlab.com/dev/CNBlogsCI-Sample 1ac80d7..683a8bc master -> origin/master Checking out 683a8bcb as master... Previous HEAD position was 1ac80d7... test commit HEAD is now at 683a8bc... test commit $ echo "Restoring NuGet Packages..." Restoring NuGet Packages... $ C:\NuGet\nuget.exe restore "src\CNBlogsCI-Sample.sln" Installing 'AutoMapper 4.2.1'. Successfully installed 'AutoMapper 4.2.1'.
gitlab-ci-multi-runner 1.1.3 (a470667) Using Shell executor... Running on DESKTOP-2P9GHDD... Fetching changes... HEAD is now at 07a6ffd Merge branch 'master' of gitlab.com:dev/CNBlogsCI-Sample From https://gitlab.com/dev/CNBlogsCI-Sample 07a6ffd..73bd820 master -> origin/master Checking out 73bd8207 as master... Previous HEAD position was 07a6ffd... Merge branch 'master' of gitlab.com:dev/CNBlogsCI-Sample HEAD is now at 73bd820... test commit $ echo "Release build..." Release build... $ C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe /consoleloggerparameters:ErrorsOnly /maxcpucount /nologo /property:Configuration=Release /verbosity:quiet "CNBlogsCI-Sample.sln" MSBUILD : error MSB1009: ��Ŀ�ļ������ڡ� ����: CNBlogsCI-Sample.sln
gitlab-ci-multi-runner 1.1.3 (a470667) Using Shell executor... Running on DESKTOP-2P9GHDD... Fetching changes... HEAD is now at eb2ec26 Update .gitlab-ci.yml Checking out eb2ec265 as master... HEAD is now at eb2ec26... Update .gitlab-ci.yml $ ls
Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 5/4/2016 10:26 AM src -a---- 5/4/2016 11:19 AM 315 .gitlab-ci.yml $ echo "Release build..." Release build... $ C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe /consoleloggerparameters:ErrorsOnly /maxcpucount /nologo /property:Configuration=Release /verbosity:quiet "CNBlogsCI-Sample.sln" MSBUILD : error MSB1009: Project file does not exist. Switch: CNBlogsCI-Sample.sln
ERROR: Build failed: exit status 1
error MSB1009: Project file does not exist.这个错误就很清晰了,项目文件找不到,也就是没有找到CNBlogsCI-Sample.sln,怎么会呢?重新查看了 Gitlab 中的项目文件目录,CNBlogsCI-Sample.sln在根目录下的src目录下,重新修改下.gitlab-ci.yml配置:
gitlab-ci-multi-runner 1.1.3 (a470667) Using Shell executor... Running on DESKTOP-2P9GHDD... Fetching changes... HEAD is now at a51aeea test commit From https://gitlab.com/dev/CNBlogsCI-Sample a51aeea..170fbc4 master -> origin/master Checking out 170fbc4a as master... Previous HEAD position was a51aeea... test commit HEAD is now at 170fbc4... test commit $ ls