我需要在git-dependencies中传递分支名称作为参数。但是在我的packages.json
中,我无法这样做。该结构如下所示:
{
"servers" : [
...
],
"target" : "apps",
"git" : {
"git-remote" : "..."
},
"source" : {
"git-dependencies-path": "../",
"source-packages-path" : "../"
},
"wiki" : {
"local-wiki-path" : "../",
"git-wiki-path" : ""
},
"git-dependencies" : [ {"repository" : "application/app1", "branch" : "development", "source-packages" : [ "."]}, //the branch name I want to parameterize}],
}
答案 0 :(得分:0)
我建议将最后一个packages.json
的主体放在.template
中,并在ci运行时简单地附加分支名称和关闭括号等。
您可以将'true'package.json
保留在git中,然后也将其覆盖。
package.json.template :
{
"servers" : [
...
],
"target" : "apps",
"git" : {
"git-remote" : "..."
},
"source" : {
"git-dependencies-path": "../",
"source-packages-path" : "../"
},
"wiki" : {
"local-wiki-path" : "../",
"git-wiki-path" : ""
},
"git-dependencies" : [ {"repository" : "application/app1", "branch" : "development", "source-packages" : [ "
gitlab-ci.yml :
- before_script: |
cp packages.json.template packages.json
echo "${CI_COMMIT_REF_NAME}" >> packages.json
echo '"]},}' >> packages.json
如果您对填写packages.json
有更多的需求,我建议使用带有string template或jinja template的python脚本