我已经开发了一个shell脚本,它可以帮助我将source.yml文件添加到所有的repos中,但是我遇到了一些问题。
需要推到所有的git (100)即。如何将source.yml文件添加到所有repos中,如何根据回购名称从元数据中更新给定的变量1,2,假设回购名称是developer,那么source.yaml文件中的元数据,变量-1,2应该替换为developer。
在这里,场景
我需要使用可变配置将一个source.yml文件添加到多个存储库(100)中
在FriendlyName(variable-2(current-reponame))where文件中,元数据由projectKey(变量-1(Current-reponame))和.yml组成,这些变量值应根据回购名称更改。
apiVersion: v9
metadata:
askId: ABCDE123-45678
caAgileId: ABC
//com.ABC is common for all repos (yourproduct.yourApp.yourComponent)
variable-1(current repo name)
// (YourApp-SomeComponent) - variable-2(current repo name)
projectKey: com.ABC.yourproduct.yourApp.yourComponent
FriendlyName: YourApp-SomeComponent
componentType: code
targetQG: GATE_77
请帮助我如何将.yml文件推入多个组织的多个存储库。
#!/bin/bash
cd $baselocation "https://github.com/xxxxxxx-xxxx/"
repocount='gitrepo.csv | wc -l'
for i in 'gitrepo.csv'
do
reponame="$i"
cd $baselocation/$i
cp source.yaml .
git add .
git commit -m "Create source.yaml"
done
发布于 2022-08-29 09:50:11
嘿,我只是做了些类似的事。这是问题的症结所在,我在当前目录中签出了所有的repos。
我并不特别推荐这个,但这是我在五分钟内完成的一项任务。
#!/bin/bash
target=some_file.yml
message="Update YAML file"
ls */.git | perl -lpe 's|/.*||' | while read -r line
do
pwd
git checkout master
git pull
... update the target here ...
git diff --exit-code $target
if [ $? -eq 0 ]
then
echo "NO CHANGES"
continue
fi
git add $target
git commit -m "$message" $target
git push origin $branch 2>&1
done
发布于 2022-09-02 12:27:25
#!/bin/bash
for i in `cat youfile.csv`
do
base_location="Directory path"
reponame=${i}
echo ${reponame}
cp Directory path/source.yaml Directory path/tmp/source.yaml
cd ${base_location}
mkdir ${reponame}
cd ${reponame}
sed -e "s/Variable-1,2/$reponame/g" '/Directory path/tmp/source.yaml'
git init
git clone https://Token@github.com/yourusername${i}.git
cd ${reponame}
cp Directory path/tmp/source.yaml .
git add source.yaml
git commit -m "Create source.yaml"
git push --set-upstream $reponame master
rm Directory path/tmp/source.yaml
cd Directory path
done
https://stackoverflow.com/questions/73525574
复制相似问题