GitLab CI. Path in yml for different users

2019-07-29 03:18发布

I'm trying to set up GitLab CI for .net project. Now I'm writing script in yml file. What I want to know: the path to the msbuild.exe and mstest.exe may be different for the different team members, how the same yml script may work for different users?
Or may be I'm understand how GitLab CI work in wrong way?

1条回答
Anthone
2楼-- · 2019-07-29 04:06

The path to the mstest.exe and all other referenced executable and files is based on the machine that has the GitLab runner running.

What's on your machine or anyone else's doesn't matter; Only the build server matters, so write your gitlab .yml accordingly.

Sample .net yml file
    ##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.
查看更多
登录 后发表回答