【发布时间】:2020-06-18 12:41:59
【问题描述】:
Shell 脚本
git clonerepo project_name project
cd project
git checkout master
git fetch "https://sam@gerrit.com:443/a/project_name" refs/changes/56/157656/1 && git cherry-pick
FETCH_HEAD
git submodule foreach --recursive 'git fetch --tags'
git submodule update --init --recursive
**#I am getting the modified files in the review here, let modified files='abc.txt cd.txt'.The modified
files are space-separated.**
modified_files=$(git diff HEAD..origin/$GERRIT_BRANCH --name-only)
cd ../
echo $modified_files
输出: abc.txt cd.txt
#在此处注入新的环境变量 MODIFIED_FILES
echo "MODIFIED_FILES=$modified_files" > $BUILD_NUMBER"_modified_files.txt"
在注入 env 变量后,我在 python 脚本中使用了这个变量。但我只得到一个文件“abc.txt”
Python 脚本
import os
modified_files = os.environ.get('MODIFIED_FILES')
print(modified_files)
输出: abc.txt
【问题讨论】:
标签: python shell environment-variables