#coding=utf8 import os import sys job_name=os.environ["JOB_NAME"] dir_path=os.path.join('/home/jenkins/workspace/',job_name) dir_lists=[] target_dir_lists=[] for root,dirs,files in os.walk(dir_path): for name in dirs: if name=='src': dir_lists.append(os.path.join(root,name).split(dir_path)[1].lstrip('/')) target_dir_lists.append(os.path.join(root,name).split(dir_path)[1].lstrip('/').split('src')[0]+'target') dir_lists=','.join(dir_lists) target_dir_lists=','.join(target_dir_lists) print(dir_lists) print(target_dir_lists)