Docker+jenkins+git Continuous Deployment practices

Source: Internet
Author: User
Tags anonymous port number docker run jenkins docker
write in front

Previously built Spring-cloud time to see someone else code inside always have Dockerfile, and then understand the concept of Docker container, play for two weeks to play, put down, inadvertently saw an article on the Internet Docker continuous deployment, think of themselves also set up a play. Process

The flow of this article on the internet involves multiple Docker images, which I'm simplifying for the sake of getting started.

The automated deployment effect is: You modify the local code and push to Git, Git's webhook function will give Jenkins post a request, Jenkins received the request, the package deployment operation, the details will say below. Docker Deployment Jenkins

Docker how to install using can refer to the previous blog.
Docker Boot:

sudo route del-net 172.16.0.0 netmask 255.240.0.0
sudo service docker start

Mirror address: https://hub.docker.com/jenkins/
The Jenkins Docker website has a direct pull down to provide image.
JENKISN Installation steps:
Pull Mirror

Docker Pull Jenkins:latest

This way startup stores the data, the-t flag is run in the future, the open port number between the-P flag container and the host server-V indicates which directory you need to mount to the container, format:-v < host directory >:< container directory >
Running the container

Docker run-t-  p 8080:8080-p 8083:8083-p 50000:50000  -v/var/jenkins_home:/var/jenkins_home Jenkins

After the operation is successful, we can enter http://ip:8080/to access the Jenkins note .

Permissions issues, specific details can be Baidu, we can first develop the user registration function, and then register a user, and then to the registered user open all permissions, anonymous user rights ticked off. One thing to be aware of is that Git's Webhok function also requires permissions, so when we configure the security matrix, we need to develop the permissions of the anonymous user's access job, otherwise git's Webhok function cannot be used.

System Configuration
Added in Global properties: Build_id=dontkillme This key value pair is very important, if not configured no matter how you run Java-jar *.jar & Project will not run in the background, because once the Jenkins deployment successfully finished executing the shell It will kill all the other processes.
Maven JDK is configured under plug-in installation
Git/publish over SSH to follow and then configure

Project configuration


The shell primarily implements the Kill legacy Java process and runs a new jar

Projectname= "Dockerjenkins.jar"
#kill
ps-ef | grep-v ' grep ' | grep ' Dockerjenkins.jar ' | awk ' {print $} ' | xargs kill-9

ps-ef|grep java

echo "Start ${projectname}"

java  -jar $WORKSPACE/target/${projectname}  &
git webhoks

Git Project address: https://github.com/ggj2010/dockerjenkins.git
Webhoks configuration:
This URL is consistent with the address of the Jenkins configuration item and can be seen by the previous screenshot triggering the remote build

Reference URL: http://www.thinksaas.cn/group/topic/378471/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.