I have the following bitbucket pipeline, which is for deploying a Meteor app with Mup.
Everything is working up until the final mup deploy command it seems to not to be able to read the generated config.json file that is supposed to have my secure mongo url injected into it.
this is what the secure_mongo.json file looks like
{
<span>"secret"</span>: $STAGING_MONGO_URL
}
In the mup file I access like
<span>var</span> mongo = <span>require</span>(<span>'./config.json'</span>);
<span>module</span>.<span>exports</span> = {
<span>MONGO_URL</span>: mongo.<span>secret</span>,
}
<span>image</span>: <span>node</span>:<span>14.16</span><span>.0</span>
<span>pipelines</span>:
<span>branches</span>:
<span>staging</span>:
- <span>step</span>:
<span>name</span>: <span>Deploy</span> to staging <span>CI</span>/<span>CD</span> <span>Environment</span>
<span>script</span>:
- mkdir -p ~/.<span>ssh</span>
- apt-get update && apt-get install gettext-base
- curl <span>https</span>:<span>//install.meteor.com/ | sh</span>
- <span>export</span> <span>METEOR_ALLOW_SUPERUSER</span>=<span>true</span>
- cd .<span>bot</span>-staging-ci-cd
- (umask <span>077</span> ; echo $DO_STAGING_CICD_SSH_KEY | base64 --decode > ~<span>/.ssh/i</span>d_rsa)
- cat secure_mongo.<span>json</span> | envsubst > config.<span>json</span>
- cat config.<span>json</span> && realpath config.<span>json</span>
- npm install -g mup
- npm install -g ssh2
- mup deployAnd I do have a secure variable named $STAGING_MONGO_URL in the repository. So Not entirely sure what is going wrong. Any help would be great.
This question is related and helped me get this far Storing secrets into Bitbucket Pipelines and then deploy on App Engine? but it is not the same question.
To be clear the error I am getting is Mup deploy is saying that the config.json file is reaching an Unexpected token
exact error
<span>Error</span> loading config <span>file</span>:
<span>SyntaxError</span>: <span>/opt/</span>atlassian/pipelines/agent/build/.<span>bot</span>-staging-ci-cd/config.<span>json</span>: <span>Unexpected</span> token m <span>in</span> <span>JSON</span> at position <span>13</span>
Also the cat command for the new config.json never reveals the secret just shows the variable $STAGING_MONGO_URL in place, I wonder if the envsubst is working at all?
Thanks