-
Notifications
You must be signed in to change notification settings - Fork 5
Jenkins Job: Build and Deploy App locally
- Create a new job. The link to get started looks something like:
https://<jenkins-server>/view/All/newJob - Type:
free style - Check
This build is parameterized - Add
String Parameter - Name:
VM_EXTERNAL_IP - Default Value:
<jenkins-server>* ex:jenkins-staging.shoppinpal.com - Add
File Parameter - Add
File Parameter - File location:
<File Location>* ex:server/boot/seed.json - Description:
<description> - In
Source Code ManagementchooseGit - Repository URL:
https://github.com/ShoppinPal/warehouse - Branch:
develop - Repository Browser select
AUTO - In
Build TriggerscheckBuild when a change is pushed to GitHub - In
BuildAdd Build StepExecute Shelland give following commands as build steps - @faisalrabbani - TODO: Is there a way to save the super long
echostring as an environment variable and then spit it out like so:echo -e $STAGING_CONFIGin the build? - @faisalrabbani - TODO: Is there some way to setup variable in Jenkins so that only the admin you created them can see the values but other jenkins users can still use them in their builds?
- @faisalrabbani - TODO: Please parameterize the following:
IW_STOCK_ORDER_WORKER_NAME, IW_OAUTH_TOKEN, IW_URL, VEND_CLIENT_ID, VEND_CLIENT_SECRET, VM_EXTERNAL_PORTand update theecho blah blahstring to make use of those variables ... both here in the docs and in the actual jenkins build
```
echo $VM_EXTERNAL_IP
echo '{ "restApiRoot": "/api", "host": "0.0.0.0", "port": 3000, "aclErrorStatus": 403, "remoting": { "json": { "limit": "50mb" } }, "site": { "baseUrl":"https://'"${VM_EXTERNAL_IP}"':3000", "proxyUrl": "" }, "logging": { "console": true, "file": false }, "prestashop":{ "apiKey":"" }, "vend":{ "auth_endpoint":"https://secure.vendhq.com/connect", "token_service":".vendhq.com/api/1.0/token", "client_id":"", "client_secret":"" }, "ironWorkersUrl":"https://worker-aws-us-east-1.iron.io:443/2/projects//tasks/webhook", "ironWorkersOauthToken":"", "stockOrderWorker":"" }' > server/config.staging.json
cat server/config.staging.json
npm install npm install grunt-cli npm install bower node_modules/bower/bin/bower install
node_modules/grunt-cli/bin/grunt deploy:staging ```
-
Add
Post-build ActionsasSend build artifacts over ssh -
Select the ssh server where your application should be deployed
-
Provide the following
Exec Commandsand leave rest of the fields empty:
rm -r /apps/warehouse cp -r /var/lib/jenkins/workspace/warehouse /apps cp server/boot/seed.json /apps/warehouse/server/boot/ cd /apps/warehouse if forever list | grep '/apps/warehouse/server/server.js' ; then echo 'stopping /apps/warehouse/server/server.js' forever stop /apps/warehouse/server/server.js fi if forever list | grep 'server/server.js' ; then echo 'stopping server/server.js' forever stop server/server.js
fi NODE_ENV=staging DEBUG=shoppinpal:,loopback:boot,boot:create-model-instances,boot:create-role-resolver,common:models:* forever start server/server.js ```
- Save Job
- Setup Jenkins on Google Cloud
- [Save a Jenkins VM image](Save a Jenkins VM image)
- [Load Jenkins Instance from Image](Load Jenkins Instance from Image)
- [Save a Node VM image](Save a Node VM image)
- [Load a VM from image](Load a VM from image)
- [Setup Nginx on Google Cloud](Setup Nginx on Google Cloud)
- Jenkins Job: Build and Deploy App locally
- Jenkins Job: Build and Deploy App remotely
- TBD