Friday 23 June 2017

[Question] Google Cloud App Deployment Script with Nodejs

I know this is just about all general node.js but I'll just try my luck here.Is it possible to do this? I'm attempting to create a deployment script with Nodejs to push an image from the Container Registry. Basically it goes:Push code into branchBuild trigger fires in Container RegistryPub/Sub message pulled after image is finished building to run scriptScript has child_process to basically run "gcloud app deploy"Issues encountered:'data' event attached to the child process isn't doing anythingI'm not sure if its running or not.Here is my code:let deploymentStream = spawn("gcloud app deploy /path/to/yaml --image-url=/path/to/image/in/container/registry", [], { shell: "/bin/bash" }); deploymentStream.stdout.on('data', data => { console.log(`stdout: ${String(data)}`); }); deploymentStream.stdout.on('message', data => { console.log(`stdout: ${String(data)}`); }); deploymentStream.stdout.on('readable', data => { console.log(`stdout: ${String(data)}`); }); deploymentStream.stderr.on('error', error => console.error); deploymentStream.on('close', code => { console.log("Staging deployment execution status " + code); }); deploymentStream.on('exit', code => { console.log("Staging deployment exit code " + code); deploying = false; }); Anyone got any idea how to do this? Or is there a better way of doing this that I am missing? Thanks.

Submitted June 23, 2017 at 08:40AM by cruzcontrol56

No comments:

Post a Comment