【问题标题】:GitLab CI. Path in yml for different users亚搏体育appCI。不同用户的 yml 路径
【发布时间】:2016-11-21 08:56:30
【问题描述】:

我正在尝试为 .net 项目设置 GitLab CI。现在我正在 yml 文件中编写脚本。我想知道的是:msbuild.exe 和 mstest.exe 的路径对于不同的团队成员可能不同,相同的 yml 脚本如何适用于不同的用户?
或者我可能理解 GitLab CI 是如何以错误的方式工作的?

【问题讨论】:

    标签: continuous-integration gitlab gitlab-ci


    【解决方案1】:

    mstest.exe 和所有其他引用的可执行文件和文件的路径基于运行 GitLab 运行程序的机器。

    您或其他人的机器上的内容无关紧要;只有构建服务器很重要,因此请相应地编写您的 gitlab .yml。

    .net yml 文件示例
        ##variables:
    ## increase indentation carefully, one space per cascade level.
    ## THIS IS YAML. NEVER USE TABS.
    stages:
       - build
       - deploy
    
     #BUILD
    # Builds all working branches
    working:
      stage: build
      except:
       - master
      script:
       - echo "Build Stage"
       - echo "Restoring NuGet Packages..."
       - '"c:\nuget\nuget.exe" restore "SOLUTION PATH"'
       # - '"c:\nuget\nuget.exe" restore "ANOTHER ABSOLUTE PATH TO YOUR SOLUTION"'
       - ''
       - echo "Building Solutions..."
       - C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe /consoleloggerparameters:ErrorsOnly /maxcpucount /nologo /property:Configuration=Release /verbosity:quiet "SOLUTION PATH"
    
    # Builds all stable/master pushes
    stable:
      stage: build
      only:
       - master
      script:
       - echo "Build Stage"
       - echo "Restoring NuGet Packages..."
       - '"c:\nuget\nuget.exe" restore "SOLUTION PATH"'
       # - '"c:\nuget\nuget.exe" restore "ANOTHER ABSOLUTE PATH TO YOUR SOLUTION"'
       - ''
       - echo "Building Solutions..."
       - C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe /consoleloggerparameters:ErrorsOnly /maxcpucount /nologo /property:Configuration=Release /verbosity:quiet "SOLUTION PATH"
    
     
     
     
     #DEPLOY
     
      stage: deploy
      only: 
        - dev
      script:
       - echo "Deploy Stage"
    #SEND TO YOUR DEV SERVER
      
      
      ## deploy latest master to the correct servers
      stage: deploy
       
      script:
      - echo "Deploy Stage"
      only: 
       - master
     #SEND TO YOUR PRODUCTION SERVER
     
      tags:
       - .NET
      #put tags here you put on your runners so you can hit the right runners when you push your code.
    
        
    

    【讨论】:

    • 在 runner 中运行时在哪里可以找到 SOLUTION PATH?
    • 解决方案路径是您正在构建的解决方案的路径。您可以相对于 gitlab-ci.yml 编写它。这是您想要构建的解决方案的路径。如果你以后想参考它,你应该看看预定义的 gitlab 环境变量。 docs.gitlab.com/ee/ci/variables/…
    • 你有部署的例子吗?
    • 根据需要使用 Xcopy 或 Robocopy 移动文件。如果您在严格的 Windows 机器上,您可能会遇到共享冲突。那是因为 gitlab runner 服务需要绑定到用户帐户才能进行跨网络复制作业。
    猜你喜欢
    • 2021-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-30
    • 1970-01-01
    • 1970-01-01
    • 2013-07-21
    相关资源
    最近更新 更多