How do I automatically deploy a Play Framework (2.4) app locally with Jenkins?

How can I automatically deploy a Play Framework (2.4) app with Jenkins to my local Jenkins server? At some point we are going to create a proper production environment separately and will probably implement test environments in the same way, but at this point I would like to check if it is possible to create a simple test environment on the same server running Jenkins.

I have a Jenkins job working and it seems to be working fine. Basically the Execute Shell commands are activated (which can be concatenated into one line).

./activator clean
./activator test

      

With Play 1 I have used play start

it play stop

for similar things too. Trying activator start

on my dev env, I get the message:

The start command is deprecated, and will be removed in a future version of Play.
To run Play in production mode, run 'stage' instead, and then execute the generated start script in target/universal/stage/bin.
To test your application using production mode, run 'testProd' instead.

      

So, I have evaluated two (incomplete) alternatives with "Execute shell" and stage:

Scene and run with nohup:

./activator clean
./activator stage
nohup target/universal/stage/bin/my-app -Dplay.evolutions.db.default.autoApply=true

      

-> the app started normally, but the Jenkins task did not stop.

Scene and launch with nohup in the background:

./activator clean
./activator stage
nohup target/universal/stage/bin/my-app -Dplay.evolutions.db.default.autoApply=true &

      

application

-> looks like it started something but didn't keep working?

What would be the preferred (or even working) way here?

+3


source to share


3 answers


In a specific case, I ended up using Docker:

  • Installed docker on the server
  • Created dockerfile based on play-docker-ci
  • Configured Jenkins
    • create docker image
    • stop existing container if running, remove existing container if exists
    • run Docker image


and it seems to be working pretty well so far.

+3


source


Jenkins kills all of its child processes when the build completes to avoid memory leaks, so the application doesn't work. The easiest way to configure jenkins with Playframework 2.4

is using sbt

tasks and sbt plugin . If you want to do a release from jenkins, the best way would be to build a debian package and install it using the jenkins shell - no process will be killed, See plugin release .



+2


source


I installed this by creating Team City with a startup.sh script that contains the command to start the Play server as a background process:

nohup /pathToApp/bin/app_name -Dhttp.port=8180 &

      

Then the next build step runs that shell script and runs it. nohup and & make this startup a background process, and when the build server shuts down, it will continue to run. For the sake of clarity, I've cut a lot of unnecessary stuff out of the startup script, but you can just add whatever startup options you want to use for your application.

0


source







All Articles