I need to pass the branch name in git-dependencies as a parameter. But in my packages.json
, I am unable to do so. The structure looks something like following:
{
"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}],
}
I suggest putting the mainstay of the final packages.json
in a .template
and simply appending the branch name and closing parens, etc at ci runtime. You can keep your 'true' package.json
in git and just overwrite it then too.
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
If you have more involved needs for filling the packages.json
I'd suggest using a python script with a string template or jinja template
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.