Search code examples
unity-game-enginegitlab-cigitlab-ci-runner

Gitlab-Runner Shell auto deletes files


I have been trying to get CI working using gitlab-runner and the shell command line using yml. My tests are run and work without a problem. The only problem I have is that when the test concludes the test results get deleted from the directory and I don't know why. When the test is running it exists for about a minute and than it disappears. There are no errors shown. gitlab-runner.exe --debug run doesn't show me anything useful either. My code is as below.

stages: 
  - edit
  - play
  - build
  
unit-test: 
  script: C:/"Unity projects"/2019.3.0f6/Editor/Unity.exe -batchmode -projectPath=. -runTests -testPlatform editmode -logFile -testResults "./unit-tests-edit.xml" | Out-Default
  stage: edit
  tags: 
    - Desktop

play-test: 
  script: C:/"Unity projects"/2019.3.0f6/Editor/Unity.exe -batchmode -projectPath=. -runTests -testPlatform editmode -logFile -testResults "./unit-tests-play.xml" | Out-Default
  stage: play
  tags: 
    - Desktop

unity-build: 
  script: C:/"Unity projects"/2019.3.0f6/Editor/Unity.exe -batchmode -logFile -projectPath=. -executeMethod WindowsBuildScript.PerformBuild -quit
  stage: build
  tags: 
    - Desktop

From what I understand this code should be correct. I had the same problem with automatic building the Unity project. After adding more stuff to my project it doesn't build at all anymore or something and I am unsure what happened. Does anybody have an idea why the files automatically delete themselves? Files in question are the unit-tests-edit.xml and the unit-tests-play. I reckon that if I am able to fix those problems the build should show up correctly as well.


Solution

  • That's because every job gets its own shell environment. You need to use artifacts to pass a file from one job to another.

    https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html