Jenkins - Docker integration - jenkins

I'm looking for the best way to integrate Docker into Jenkins to execute build/test commands.
The best source I have found is this blog post:
http://blog.howareyou.com/post/62157486858/continuous-delivery-with-docker-and-jenkins-part-i
It basically offers to wrap all execution commands with "docker run".
I would like to see better integrations with Jenkins plugin but I couldn't find anything in this area.
Could anyone suggest a good way to proceed? Is there any project on the way to address this?
Thanks

There's a second blog post which goes into more detail about the setup. The missing piece was dockerize which makes the Jenkins & Docker integration painless. If you look into the Ruby app example, there's a Vagrantfile which will set everything up for you, use that as the starting point for your own setup.

Wouldn't you just create a shell script to setup the docker environment as you normally would (or better still push the docker container in to a private repo) and get Jenkins to pull it down and run the test suite inside docker using the daemonised mode?
Maybe you could use directory shares to drop the output of the test data so that Jenkins can read it and display?
Hopefully a point in the right direction...

This plugin might be what you are looking for.

Related

Jenkins to execute shell script located on remote server

I started to pick up Jenkins recently and want to see how it will fit my working environment. One of the very first tasks I want to do is to create a Jenkins project that will run a bash script located on a remote server via ssh, not copy a local script to a remote server then run it.
I could not find much helpful information online and pretty much have no idea where to start. I am pretty sure others may have the same questions, so thought to ask it here.
Thanks

How to deploy weblogic application as docker container completely using Dockerfile?

I've a simple REST API in the weblogic application. I've to deploy the application as the docker container. But, I'm facing a problem in defining the Dockerfile.
Dockerfile
FROM store/oracle/weblogic:12.2.1.4
COPY target/app.war /u01/oracle
Above is my current Dockerfile. With the current dockerfile, I have to manually deploy the application on the weblogic server. We would like to automate the application deployment using Dockerfile and didn't get the exact examples.
Please advise.
This is a complex task, so it is hard to explain the whole process here.
The high-level steps that you need to execute are the followings:
Start a properly configured WebLogic domain in Docker. This task involves the creation of the admin and managed servers and WL cluster, etc.
Build the application that you wanna deploy
Configure the database properly if you have any
Create the WL resources like connection pool, JMS, etc manually or via WLST script
Deploy your artifact via the WL web console or with WLST script or copy the file under the autodeploy directory
Be careful because the tasks that you executed manually will be lost if you drop your docker container.
You can find concrete examples, use cases, automated scripts that you can use and well prepared, ready for use WebLogic Docker images here: https://github.com/zappee/docker-images
If you have a concrete question, not a general one, like this, then please start a new thread.
Take a look at the GitHub project:
https://github.com/oracle/docker-images/tree/master/OracleWebLogic/dockerfiles

Jenkins + Artifactory in Red Hat

Good morning, I have a server with Red Hat Enterprise 7.6 (it can only be this one) installed and I have to install jenkins + jfrog artifactory.
The easiest way to do this would be with docker or installing them on the machine? The docker I already installed them but I do not know which is the most correct way to use them.
The docker seems to me better in the matter of I need to have other tools in that server and everything in container. In the future this machine will also have gitlab.
Thank you for your help
Docker Compose will be your best option and is the recommended option from JFrog's point of view for the scenario you're describing. We've added a bunch of examples of docker-compose scripts to our GitHub repos that should give you a great start.
You can user docker-compose tool.
Combine all required services in one yaml file.

Chef and Docker

I am a bit confused. As a part of a course we are supposed to setup a CI and CD solution using Jenkins, Docker and Chef, how the flow is going to be is not specified.
We have been setting up Jenkins, so that for every new git commit it creates a Jenkins slaves that spins up the specific containers needed for a test, then tears down them and reports the result.
So, have been looking around today for information regarding using Chef and Docker for continuous delivery/deployment. The use case that I see is the following, specify in Chef the machine deployment options, how many machines for each server, database and so on. When the Jenkins slave successfully builds and tests the application, it is time to deploy. Remove any old container and build new containers, handle configurations and other necessary management in Chef.
Have been looking around for information of similar use cases and there does not seem to be super much information about it. Have been tinkering with the chef-provision plugin with chef-provision-docker but the information regard to using for example the docker plugin is not super intuitive. Then I stumble across this article (https://coderanger.net/provisioning/) which basically does not recommend new projects to start using the chef-provision plugin.
Is there something I am missing, is this kind of use case not that popular or even just stupid? Are there any other plugins that I have missed or another setup with chef that is more suitable?
Cheers in advance!
This kind of purely procedural stuff isn't really what Chef is for. You would want to use something integrated directly with Jenkins as a plugin probably. Or if you're talking about cookbook integration tests there are the kitchen-docker and kitchen-dokken drivers which can handle the container management for you.
EDIT: The above was not really what the question was about, new answer.
The tool you're looking for is usually called a resource scheduler or cluster orchestrator. Chef can do this either via chef-provisioning or the docker cookbook. Between those two I would use the latter. But that said, Chef is really not the best tool for this job. There is a whole generation of dedicated schedulers including Mesos+Marathon, Kubernetes, Nomad, and docker-compose+swarm. Of all of those, Nomad is probably the simplest but Kube has a huge community following and is growing quickly. I would consider using Chef for this an intermediary step at best.
I would suggest to use container orchestrations platforms like kubernetes, docker swarm or mesos. Personally i would recommend to use kubernetes since it is the leading platform out of the three listed.
chef is a good configuration management tool and using it for provisioning containers would work but it is not the best solution. You would come across issues like managing where the containers should be provisioned and monitoring container status and how to handle their failures. A platform like kubernetes would handle this for you.
this would be useful to get some insigths:
https://www.youtube.com/watch?v=24X18e4GVbk
more to read:
http://www.devoperandi.com/how-we-do-builds-in-kubernetes/

In Jenkins, how do you rename a job using the CLI?

I've been reading this wiki article about the Jenkins CLI. Is there a way to rename a job through the CLI? I can't seem to find a way. An obvious workaround would be to copy a job then delete the old one, but I'm hoping there's a more straight forward way.
For what it's worth, I had to rename a larger number of jobs and was hoping on the CLI. There is no dedicated rename command. I did not try to get-job and then push a changed version up again, maybe that would work.
I have no direct access to the Jenkins machine and thus cannot mess around on the file system, like some suggested.
I resorted to a manual approach, with some clicking - maybe this is viable workaround for others: https://.../jenkins/job/OLD-JOB-NAME/rename?newName=NEW-JOB-NAME - this will give you a "are you sure" prompt, which after confirming should rename the job.
I wouldn't bother with Jenkins' own CLI. If you just navigate to the Jenkins jobs' directory on your filesystem and rename the job using the 'mv' unix command, then refresh Jenkins it should be fine. (you may have to reload the config from the disk in the Jenkins settings if refreshing doesn't work)

Resources