Running Serverless Framework CLI commands, like "deploy", from Maven - java

What I am trying to do:
Build the (AWS Lambda function) Java Maven module, with the mvn command and goals, as usual.
Depending on given custom goals, Maven will call Serverless CLI commands to deploy the Java based Lambda function, using the serverless.yml file in the root dir of the module.
Maven continues with end to end test, using URLs returned by Serverless CLI command call (deploy). Or by sending messages to a queue, if that's the event triggering the function.
So, I've been searching for a Maven plugin for Serverless Framework CLI, but I can't find anyone. I really want Maven to execute the Serverless CLI when certain goals are given.
This is what I think my options might be, right now:
Write the Maven plugin myself.
Use shell scripts, I consider it ugly, but thats subjective.
Get a tip of a Maven plugin I've missed.
Another slick way to accomplish what I want, that I'm unaware of.
I appreciate all ideas, but really I'm focusing to solve this within the Maven lifecycle.

Another slick way to accomplish what I want, that I'm unaware of
I think a way the achieve this is to add the scripts to a step in your build server. Maven's primary function is to act as a build manager which is slightly different from the deployment use case you are outlining above.

If anyone is still intrigued by this I've started an inspired effort at https://github.com/olensmar/serverless4j/tree/master/maven-plugin - still working on how this would optimally fit in the maven lifecycle - ideas/suggestions as always welcome!

Related

Does ci.gitlab.com support hosted Java builds?

I'm trying to understand what is provided by ci.gitlab.com. I would like to create a build using Gradle for my Java project and have it all run on ci.gitlab.com servers.
The process for adding a runner seems to involve leveraging a localized installation of GitLab CI. There are shared runners available, but they seem to be geared toward Ruby, Node, etc.
Is it possible to use ci.gitlab.com for a fully hosted CI solution?
Its not important if there are only Ruby, Node or other Runners. If they are shared runners, you can specify the image in your .gitlab-ci.yml which the runners use to run you tests. See here (i wrote a example .gitlab-ci.yml):
The runners will pull the right image and will run your tests in the specified image.
More information here.

Tried and tested ways to automate load tests with Maven

I'm trying to figure out the best way to automate the execution of and result recording of load tests. We currently use Maven; ideally the solution would be executed as part of the Maven project life-cycle, so that people do not need so spend time on effort setting up the tests.
It should save the output of the tests (e.g. as some files that could be committed into version control), and should have the sense to not compare tests run on a dusty x486 with a 8 core Sparc.
JMeter is another Apache project which is very well adapted for automation (you can control most things from the command line); there are also several plugins that you can use to integrate it into Maven. Personally, I think this is by far the best tool for this sort of requirement.
You still need to create the actual tests to run and decide which environment to use - but this will always be the case no matter which tool you choose.
Have a look here, here and here.

What are the best methods for deploying java code to production?

Currently we have a Java Restlet API with dependencies controlled via Maven. When we update the API we run maven assembly:assembly which does the unit tests etc and produces a single jar file. We then upload this to the production server and run it using nohup.
Is there a better or more automated way of doing this? Is this where something like Hudson would come in?
Thanks
My experience goes with webapp-deployment. But same should hold true here. Use Maven, Cargo, Nexus (or Artifactory), Hudson and probably, Jira in conjunction of product release.
Automated release process are more reliable because there is no human factor involved that may forget a step.
We also use Liquibase for database versioning. And, if you are dealing with database changes in your application deployment. You'll realize Liquibase boosts so much confidence while running alter scripts.
I would suggest to go through the following resources
Automated Deployment with Maven - going the whole nine yards If you can, literally follow this pattern.
Maven 2 Effective Implementation -- this book really helped us a lot.
There are several Maven plugins to help deployment. The most general of them is Cargo, but there are also app server specific plugins for some concrete servers like JBoss.
Most companies I have worked for (actually, all) have had some sort of custom in-house built deployment system; even if build was done using a standard framework (like Maven in use at my current company).
Part of this is because there are many aspects that tie closely to company-specific infrastructure, capacity management and monitoring systems; and so even though there are open-source systems, there is usually something that needs to be tweaked.
It sounds like you are running your app on its own--it isn't part of any application server. If you aren't using an application server, there are probably some ways to get cargo and maven to deploy it for you, but you may be better off just using some shell scripts to deploy and run the application.
However, as your application grows, you may find a need for an application server like Jetty, JBoss, Glassfish, Tomcat, etc. When this happens, take a look at the cargo plugin for Maven because it will allow you to do something like:
mvn cargo:redeploy
That will package up your application, send it to the server and restart the app. If you want Hudson to do this for you automatically you can add it as a target to build.
Cargo can save you a lot of time when you have to frequently update an application server.

What is the best way to handle Java web application versioning?

I have a standard Java application that handles both REST and UI calls. What is the best way for me to create and manage an application version (major.minor.release.build)? I'm using Subversion, Maven, Bamboo (continuous build) and Spring in the stack. I would like the version to be tied together with SVN, Bamboo and Maven. And, would like to be able to log version on start-up -- likely using some Spring bean.
There must be a framework/pattern out there to help with this. I'd rather not roll my own.
Thank you!
Why not use Semantic Versioning? It is what most people expect nowadays, it is pretty well defined and it is out there. Good enough for me.
Maven has a release plugin. This is a bear to setup first but once it is working it works well. It does all the nitty gritty of making sure everything is cleanly checked in, tagged properly, and does the magic with the version numbers. It is not a ask to look forward to, but at least now it is properly done. It pays to setup some maven repository. We use Nexus and can recommend that, but I heard good things of artifactory too.
During testing we do not rely on the maven version too much but on the build number, which we put in a discrete place on the web pages and similar artifacts so we can quickly determine which exact build we're talking about. We use hudson which provides the build number in an environment variable, but Bamboo must provide that too. The filter copy functionality makes that pretty straightforward.
Hudson tags the VCS (we use git, but that does not matter) with the build number and the maven release plugin tags the releases.
You can include the SCM revision number in your artifact using the maven build-number plugin (http://mojo.codehaus.org/buildnumber-maven-plugin/), e.g. in a filtered resource, such as a properties file.
If you are using Artifactory as your binary repo then it can also tag your binary artifacts with a build number and have full traceability from your artifact to the CI server build that created it. Currently this is supported with Hudson, TeamCity and Bamboo.

Is there good deployment and administration for Java environments?

We already have a good build server in Hudson but we want something that would let us startup and shutdown servers, push out new deployments of software (which is much more involved than just a single WAR or EAR going somewhere, there is copying, extracting, renaming, etc.), and various other tasks we would like to automate.
I've looked at SmartFrog (seems largely academic rather than commonly used), ControlTier (a dose of heavy complexity to go with your complexity), Capistrano (Ruby and Rails focused), and Func (no docs at all, their MediaWiki has been wiped). Is there nothing that is a good 80/20 solution for this kind of thing. Surely you could have a tool that would offer a lot of what ControlTier offers without all the overhead.
The alternative is Ant scripts to do everything (possibly available through our existing Hudson server) or even a Hudson plugin of some type but that feels kludgy to me and I'm just not liking it as a solution (plus we might be rebuilding something when we don't need to).
Please, tell me about a good alternative.
We are using Ubuntu only and use Debian packages to distribute builds across our servers and control them with init scripts. It's also great to setup a new server. Just add dependencies to Java, MySql and whatever you need and you'll be up and running a new deployment within seconds.
You might want to try Cargo. You can use ant and maven for the deployment definition you want and then set Hudson to point at your ant's build.xml or maven's pom.xml.
Chef was mentioned here but I have no experience with it.
There is also Puppet that you need to check out. You might need to read this great whitepaper on achieving fully automated provisioning
-Ken
LiveRebel might be a suitable tool for this task. It provides CLI API and also a Hudson/Jenkins plugin for automation

Categories

Resources