-->

Bamboo - Angular 4 app How to deploy

2020-07-25 09:23发布

问题:

How to deploy my angular 4 application on bamboo?

I just make a simple job with 1. git 2. npm install 3. ng build

This passes succesfully, but what I should make next? How to deploy this on server, that i could get into app from browser?

I tried to deploy this on tomcat, but i don't have any war.

I don't know what to do

回答1:

Here are the tasks I use to setup a Bamboo deployment plan:

  1. Source Code Check Out Task: this is a standard task in Bamboo were you feed it the source code repository to deploy (for more information see: https://confluence.atlassian.com/pages/viewpage.action?spaceKey=BAMBOO0603&title=Checking+out+code

  2. NPM Task: use this command cache clean -f to clear cache of server node_modules which could cause permission issues if you don't (for more information see: https://confluence.atlassian.com/bamboo/getting-started-with-node-js-and-bamboo-687213472.html#GettingstartedwithNode.jsandBamboo-npmtask and Npm Please try using this command again as root/administrator)

  3. NPM Task: use this command i to install/refresh all node_modules on the server for the current project

  4. NPM Task (optional): use this command i -g @angular/cli to install/update angular-cli on the server. You may or may not want to do this every time if you're concerned with locking your source versions.

  5. NPM Task: use this command run ng build to build (transpile) your source code (es5 compatibility etc.)

  6. Script Configuration Task: run this command xcopy "${bamboo.build.working.directory}\..." "[some output directory goes here]" /E /Y(for more information about the script config task, see: https://confluence.atlassian.com/display/BAMBOO0603/Script)

There can be other tasks for running test, etc. but the above will get you started.



回答2:

There are a number of options. If you really want to stick with Tomcat, it is possible to serve static files - it involves editing a Tomcat config file to specify a context root folder, and then you would just copy your static files generated in bamboo to that folder. You are correct that you could not use the Tomcat Task in Bamboo to do this though, as that is specific to war deployments, it would just be an SCP or Shell task. You can search serving static files from Tomcat to see how to do this.

Alternatively, you can build a war containing the static files, and this is what I see done most often at my place of employment. You can add maven to your project to accomplish this, or do it with gulp or similar js-based tool.

Alternatively squared, use a web server locally that is not a java container, and more friendly to static content - nginx for example. That removes need to build a war. To deploy to this would probably be an SCP task if it is a remote server, rather than a custom bamboo task specific to that server type (apache, nginx, etc.)