1

I have a Jenkins container in docker.

When I build something successfully, I want to deploy it to a glassfish docker container.

https://docs.oracle.com/cd/E19798-01/821-1757/ghgmi/index.html

Mentioned on the given website, copying a war in the autodeploy folder will auto deploy it. But how do I connect to the glassfish container?

https://github.com/jenkinsci/postbuildscript-plugin

With this plugin you can execute a script after building.

yooouuri
  • 2,578
  • 10
  • 32
  • 54
  • may be you can use this plugin https://wiki.jenkins.io/display/JENKINS/Deploy+Plugin or try this to execute following in jenkins https://stackoverflow.com/a/53032249/5227589 – Dev Oct 31 '18 at 17:53
  • do you know any other way to deploy to glassfish from jenkins – Dev Oct 31 '18 at 17:56

1 Answers1

1

I use Jenkins Pipeline job to control my containers.

In that case, you can use something like this in your pipeline script:

node ("YOUR_SLAVE_MACHINE_NAME") {
    stage('Build Image'){

        app = docker.build('NAME_OF_IMAGE:latest', '/jenkins_home/workspace/NAME_OF_THIS_JOB')

    }

    stage('Run container') {
        try {
            app.inside(' -p 8080:8080 ') { // or any properties you want to deliver

                sh '/usr/local/glassfish4/bin/asadmin start-domain'
                sh '/usr/local/glassfish4/bin/asadmin -u admin deploy /YOUR_APP.war'
                sh '/usr/local/glassfish4/bin/asadmin stop-domain'
                sh '/usr/local/glassfish4/bin/asadmin start-domain --verbose'
                sh 'sleep 10000d'
            }
        }
        catch (exc) {
            echo 'Application container is down. ' + exc 
        }
    }
}
Asaf
  • 21
  • 4