[英]How to pass variable from GitLab CI Linux job with artifacts to a job which, is executed with shell-windows-runner
I have two jobs on a GitLab pipeline: In the first one I save a value into a txt file in order to share this value through an artifact to the next job.我在 GitLab 管道上有两个作业:在第一个作业中,我将一个值保存到一个 txt 文件中,以便通过工件将这个值共享给下一个作业。 The second one is a do.net job and I would like to get the value from the txt file I populated in the job1 an save this value into a variable.
第二个是 do.net 作业,我想从我在 job1 中填充的 txt 文件中获取值,并将该值保存到一个变量中。
stages:
- stg1
- stg2
job1:
stage: stg1
script:
- echo ${NEW_VERSION} > build.txt
artifacts:
expire_in: 1 week
paths:
- build.txt
variables:
NEW_VERSION: "1.2.3"
job2:
stage: stg2
needs: [job1]
tags:
- dotnet
script:
# Here I need to get value from build.txt and set it into the $NEW_VERSION variable
- '& "$NUGET_PATH" dotnet restore'
- '& "$MSBUILD_PATH" /nologo /p:Configuration=Release'
- 'mkdir target'
- 'Add-Type -assembly "system.io.compression.filesystem"'
- '[io.compression.zipfile]::CreateFromDirectory("$CI_PROJECT_DIR\$EXE_RELEASE_FOLDER\", "$CI_PROJECT_DIR\target\$PACKAGE_NAME-$NEW_VERSION.zip")'
artifacts:
expire_in: 1 week
paths:
- build.txt
dependencies:
- job1
variables:
NEW_VERSION: ""
Finally I found the solution to the problem by using '$NEW_VERSION=type.\build.txt'
so the final YAML would be:最后,我通过使用
'$NEW_VERSION=type.\build.txt'
找到了问题的解决方案,因此最终的 YAML 将是:
stages:
- stg1
- stg2
job1:
stage: stg1
script:
- echo ${NEW_VERSION} > build.txt
artifacts:
expire_in: 1 week
paths:
- build.txt
variables:
NEW_VERSION: "1.2.3"
job2:
stage: stg2
needs: [job1]
tags:
- dotnet
script:
- '$NEW_VERSION=type .\build.txt'
- '& "$NUGET_PATH" dotnet restore'
- '& "$MSBUILD_PATH" /nologo /p:Configuration=Release'
- 'mkdir target'
- 'Add-Type -assembly "system.io.compression.filesystem"'
- '[io.compression.zipfile]::CreateFromDirectory("$CI_PROJECT_DIR\$EXE_RELEASE_FOLDER\", "$CI_PROJECT_DIR\target\$PACKAGE_NAME-$NEW_VERSION.zip")'
artifacts:
expire_in: 1 week
paths:
- build.txt
dependencies:
- job1
variables:
NEW_VERSION: ""
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.