Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Jenkins mirroring

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to use Jenkins image, the article is very detailed, has a certain reference value, interested friends must read it!

How to use the mirror $docker run-p 808080 index.csphere.cn/microimages/jenkins

This startup will store all workspace in the / var/jenkins_home directory, including all data, plug-ins, and configurations, which you may want to run in a persistent data volume:

$docker run-- name myjenkins-p 8080Vue 8080v / var/jenkins_home index.csphere.cn/microimages/jenkins

The volumes in the myjenkins container will be persisted, or you can map a host directory:

$sudo chown 999 / your/home$ docker run-p 8080 your/home:/var/jenkins_home index.csphere.cn/microimages/jenkinsjenkins 8080-p 50000 your/home:/var/jenkins_home index.csphere.cn/microimages/jenkinsjenkins 50000-v administrator user

After the jenkins image is started, you will be prompted to enter the user name and password when you open the browser http://your-ip:8080,. Here, the default user name is admin and the password is admin. Change the password in the user menu after entering.

How to combine with docker

The biggest advantage of docker lies in deployment, and the most powerful of jenkins lies in job scheduling and plug-in system. How to combine the two?

The docker client command line tool, / usr/bin/docker, is built into the jenkins image, so we only need to pass DOCKER_HOST environment variables or map the docker.sock file to the jenkins container to make the jenkins container have the ability to operate docker, and then combine the two.

For example:

Docker run-p 8080 var/run/docker.sock:/var/run/docker.sock index.csphere.cn/microimages/jenkins 8080-p 50000-v / your/home:/var/jenkins_home-v / 50000-v

Then we can add an execute shell script to our jenkins project, as shown in the following example:

TAG=$ (echo $GIT_COMMIT | awk'{string=substr ($0,1,7); print string;}') docker build-t demo:$TAG .docker run-- rm demo:$TAG run_testdocker tag-f demo:$TAG your_registry/demo:$TAGdocker push your_registry/demo:$TAG backup data

If you mount the host directory into the container, you can back up the directory. This is also the method we recommend. Think of the / var/jenkins_home directory as a database directory.

If your volume is in a container, you can copy out the data with the docker cp $ID:/var/jenkins_home command.

If you are interested in docker data management, you can read Managing data in containers

Set the number of actuators

You can specify the number of jenkins master executors through the groovy script. The default is 2, but you can expand the image:

# executors.groovyJenkins.instance.setNumExecutors (5)

And Dockerfile

FROM index.csphere.cn/microimages/jenkinsCOPY executors.groovy / usr/share/jenkins/ref/init.groovy.d/executors.groovy to build executors

You can build on master, but if you want to build on slave, you must do a 50000 port mapping, which is used to connect to slave agent.

Pass JVM parameters

You may want to modify the running parameters of JVM, such as heap memory:

$docker run-- name myjenkins-p 8080VR 8080-p 50000Rod 50000-- env JAVA_OPTS=-Dhudson.footerURL= http://mycompany.com index.csphere.cn/microimages/jenkins configuration log

Jenkins logs can be configured through java.util.logging.config.fileJava property

$mkdir data$ cat > data/log.properties

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report