需要将.yml文件推送到多个存储库,并进行自定义修改

0 人关注

我开发了一个shell脚本,可以帮助我将source.yml文件添加到所有的repos中,但是我遇到了一些障碍

需要推送到所有的git仓库(100个),即如何将source.yml文件添加到所有的仓库中。 如何根据 repo 名称更新元数据中的变量 1,2 假设 repo 名称为 developer,那么 source.yaml 文件中的元数据,变量 1,2 应该替换为 developer。

这里的情况是

我需要将一个source.yml文件添加到多个资源库(100个)中,配置可变。

In .yml file, metadata consists of projectKey(variable-1(Current-reponame)) & FriendlyName(variable-2(current-reponame))where these variable values should change according to repo name

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'
 reponame="$i"
 cd $baselocation/$i
 cp source.yaml .
 git add .
 git commit -m "Create source.yaml"
    
linux
bash
git
shell
yaml
Marshal Sriraj
Marshal Sriraj
发布于 2022-08-29
2 个回答
brian d foy
brian d foy
发布于 2022-09-02
0 人赞同

嘿,我刚刚做了类似的事情。这里是问题的关键,我在当前目录下检查了所有的仓库。

我并不特别推荐这个,但这是我在五分钟内为这个周末的任务所做的事情。

#!/bin/bash
target=some_file.yml
message="Update YAML file"
ls */.git | perl -lpe 's|/.*||' | while read -r line
    git checkout master
    git pull
    ... update the target here ...
    git diff --exit-code $target
    if [ $? -eq 0 ]
      echo "NO CHANGES"
      continue
    git add $target
    git commit -m "$message" $target
    git push origin $branch 2>&1
    
我已经在上面阐述了这个问题,请帮助我。
好吧,在你的例子中,你遗漏了推动。
Marshal Sriraj
Marshal Sriraj
发布于 2022-09-02
0 人赞同
#!/bin/bash
for i in `cat youfile.csv`
 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"