Report this

What is the reason for this report?

How do I deploy my Jenkins build on a droplet?

Posted on January 25, 2020

I have Jenkins set up with nginx in a docker container on a droplet. I installed the plugin Deploy to Container on Jenkins. Now I need to set up a Tomcat server to deploy the Jenkins war file to.

So where does my Tomcat server go? And why do I need another server when I have a droplet already? Do I need a new docker container on my droplet for the tomcat server?

My Jenkinsfile deploy stage currently looks like this, but I need to context?

stage('Deploy') {
            steps {
                echo 'Deploying...'
                sh 'deploy contextPath: null, war: "/usr/share/jenkins/jenkins.war"'
            }
        }


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello,

It would not be a problem to run your Tomcat server on your existing Droplet. You can take a look at this tutorial here on how to install Tomcat on your Droplet:

https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04

Regarding the Pipeline itself, it would really depend on what setup you would like to have at the end, for example, if you like Jenkins to build your Java project and then containerize it and deploy it on the same server? If this is the case you could have a similar setup to this one:

https://www.digitalocean.com/community/questions/running-jenkins-in-docker

That way your Jenkins container would have access to the Docker service on your host, and you can spin up containers from inside Jenkins and start them on your Droplet directly.

If you prefer not to run your app in a container, you could take another approach and share a volume between your Jenkins container and your Droplet, then with the copy command that you already have, you could copy the war file from your Jenkins container to the share volume so that the war file would be available on your Droplet where you could have your Tomcat running.

Regards, bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.