Deploy to JBoss from Docker Jenkins Container - jenkins

I have a docker Jenkins container running on RHEL host machine that pulls out code from TFS and builds a war using Ant scripts. After the build is complete we want to push the war to a JBoss running on our RHEL host. What is the best way to do this?
We have the Jenkins home mounted to a directory on the host system and I able to manually deploy the war from this directory onto the JBoss server using the jboss-cli deploy script.
When I am inside my Jenkins container running the build can I use the file system on the host to run the jboss-cli script?

No. You can not run scripts on the host from within a container.
One solution may be to share a volume between both Jenkins and JBoss containers. This way Jenkins can deploy the war to this directory and JBoss will be able to access it.
But you cannot use the Jenkins container to run a script on the host.
If you do need to execute a script, you could link the containers (ie. add them to the same docker network). You could build the JBoss container with SSH on it, and your Jenkins job could include a step to run a command on the JBoss container via SSH.

Related

Cannot run program "docker": error=2, No such file or directory in jenkins

I installed Jenkins on AWS and installed dockerhub on my local machine. When i created a pipeline job in Jenkins and build then I got an error in last build stage.
https://github.com/Raahatx8/docker
I used above repo to create my pipeline, it includes dockefile and jenkinsfile.
This is the error
Your remote machine i.e. AWS doesn't have connection to the Docker daemon (which is in the local machine) to run the docker commands.
In order to achieve the same i.e. to run the docker commands, you need to do two things:
Enable Docker Remote API (in your local machine where docker is installed)
Download docker client (in AWS machine)
Refer to guide: https://gist.github.com/kekru/4e6d49b4290a4eebc7b597c07eaf61f2
Note: Make sure you need to open connection to particular port in local machine, so that AWS machine can connect.

how can i deploy WAR files on Tomcat using Oracle and ActiveMQ in Docker?

I want to deploy all my application war files on tomcat container running in docker which is dependent on Oracle 12c Container and ActiveMQ container. What will be good approach?using docker-compose or executing 3 different images?
Anything that can done by running individual docker containers can be done using docker-compose. In fact docker-compose is built for defining and running multi-container Docker applications.

Running docker containers as Jenkins Slave

I have Jenkins installed on my system and I want to run docker containers as Jenkins slave.
I am confused with the configuration part of jenkins after installing docker plugin.
What should I enter in those settings?
You'll need to edit Jenkins system configuration (Jenkins > Manage > System configuration) and add a new Cloud of type "Docker"
That means you need to have docker installed in a cloud (a local one like VirtualBox, or a remote one, like Amanzon EC2.
See for instance "Using Docker as a Jenkins Cloud Provider".

How to run build on docker container in coreos?

I have installed CoreOS as my build environment. I installed Jenkins server as a docker container in CoreOS. And I created a free style project on the Jenkins server to build my project. How can I configure the build run on docker containers on the CoreOS?
So the structure is: CoreOS is my physical machine. Jenkins server is running in a docker container in the CoreOS. And I want to launch more docker containers to run my application. How can I achieve this? The hardest part I think is to launch a docker container in CoreOS from Jenkins JOB. I want to start a new docker container ever time for a build.
I'm not familiar with Jenkins, but I would suggest that you take a look at the docker-machine and docker-compose utilities.
You should be able to have Jenkins use one of those to have the host start your build container.

Jenkins shell script execution on different server

I have two VM, on one VM I have docker and on another I have Jenkins .I have shell script for running docker, which is placed on server which have docker on it. But I need Jenkins to execute this shell script, from pre-build step.
I am facing problem with this process.
It will be very helpful if any one can provide the detail steps
Thanks in Advance
There are different approaches to achieve that.
One is to install Jenkins slave on the VM which has docker on and have your Jenkins master run the whole job on the slave.
Or you could install one of Publish Over SSH Plugin or SSH plugin to execute commands remotely (if your docker VM has SSH access)
If your network is sufficiently secured from the outside, you could expose the docker API socket via a TCP port on your docker-machine and run the docker commands from your jenkins machine, using the remote tcp-port.
Basic idea is outlined here in the section "Bind Docker to another host/port or a Unix socket"
Cheers D

Resources