在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):jenkinsci/docker开源软件地址(OpenSource Url):https://github.com/jenkinsci/docker开源编程语言(OpenSource Language):Dockerfile 35.5%开源软件介绍(OpenSource Introduction):Official Jenkins Docker imageThe Jenkins Continuous Integration and Delivery server available on Docker Hub. This is a fully functional Jenkins server. https://jenkins.io/. Usage
NOTE: read the section Connecting agents below for the role of the This will store the workspace in
This will automatically create a 'jenkins_home' docker volume on the host machine. Docker volumes retain their content even when the container is stopped, started, or deleted. NOTE: Avoid using a bind mount from a folder on the host machine into
this will run Jenkins in detached mode with port forwarding and volume added. You can access logs with command 'docker logs CONTAINER_ID' in order to check first login token. ID of container will be returned from output of command above. Backing up dataIf you bind mount in a volume - you can simply back up that directory (which is jenkins_home) at any time. This is highly recommended. Treat the jenkins_home directory as you would a database - in Docker you would generally put a database on a volume. If your volume is inside a container - you can use For more info check Docker docs section on Use volumes Setting the number of executorsYou can define the number of executors on the Jenkins built-in node using a groovy script. By default it is set to 2 executors, but you can extend the image and change it to your desired number of executors (recommended 0 executors on the built-in node) :
and
Connecting agentsYou can run builds on the controller out of the box. The Jenkins project recommends that no executors be enabled on the controller. In order to connect agents through an inbound TCP connection, map the port: If you are only using SSH (outbound) build agents, this port is not required, as connections are established from the controller. If you connect agents using web sockets (since Jenkins 2.217), the TCP agent port is not used either. Passing JVM parametersYou might need to customize the JVM running Jenkins, typically to adjust system properties or tweak heap memory settings.
Use the
JVM options specifically for the Jenkins controller should be set through Configuring loggingJenkins logging can be configured through a properties file and
Configuring reverse proxyIf you want to install Jenkins behind a reverse proxy with a prefix, example: mysite.com/jenkins, you need to add environment variable Passing Jenkins launcher parametersArguments you pass to docker running the Jenkins image are passed to jenkins launcher, so for example you can run:
This will show the Jenkins version, the same as when you run Jenkins from an executable war. You can also define Jenkins arguments via
You can also change the default agent port for Jenkins by defining
or as a parameter to docker,
Note: This environment variable will be used to set the
system property
Installing more toolsYou can run your container as root - and install via apt-get, install as part of build steps via jenkins tool installers, or you can create your own Dockerfile to customise, for example:
In such a derived image, you can customize your jenkins instance with hook scripts or additional plugins.
For this purpose, use
Preinstalling pluginsInstall plugins scriptYou can rely on the plugin manager CLI to pass a set of plugins to download with their dependencies. This tool will perform downloads from update centers, and internet access is required for the default update centers. Setting update centersDuring the download, the script will use update centers defined by the following environment variables:
It is possible to override the environment variables in images. Installing Custom PluginsInstalling prebuilt, custom plugins can be accomplished by copying the plugin HPI file into
UsageYou can run the CLI manually in Dockerfile: FROM jenkins/jenkins:lts-jdk11
RUN jenkins-plugin-cli --plugins pipeline-model-definition github-branch-source:1.8 Furthermore it is possible to pass a file that contains this set of plugins (with or without line breaks). FROM jenkins/jenkins:lts-jdk11
COPY --chown=jenkins:jenkins plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.txt When jenkins container starts, it will check In case you do want to override, append '.override' to the name of the reference file. E.g. a file named
Also see JENKINS-24986 Here is an example to get the list of plugins from an existing server:
Example Output:
For 2.x-derived images, you may also want to
to indicate that this Jenkins installation is fully configured. Otherwise a banner will appear prompting the user to install additional plugins, which may be inappropriate. Updating plugins fileThe plugin-installation-manager-tool supports updating the plugin file for you. Example command: JENKINS_IMAGE=jenkins/jenkins:lts-jdk11
docker run -it ${JENKINS_IMAGE} bash -c "stty -onlcr && jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.txt --available-updates --output txt" > plugins2.txt
mv plugins2.txt plugins.txt UpgradingAll the data needed is in the /var/jenkins_home directory - so depending on how you manage that - depends on how you upgrade. Generally - you can copy it out - and then "docker pull" the image again - and you will have the latest LTS - you can then start up with -v pointing to that data (/var/jenkins_home) and everything will be as you left it. As always - please ensure that you know how to drive docker - especially volume handling! Upgrading pluginsBy default, plugins will be upgraded if they haven't been upgraded manually and if the version from the docker image is newer than the version in the container. Versions installed by the docker image are tracked through a marker file. To force upgrades of plugins that have been manually upgraded, run the docker image with The default behaviour when upgrading from a docker image that didn't write marker files is to leave existing plugins in place.
If you want to upgrade existing plugins without marker you may run the docker image with HackingIf you wish to contribute fixes to this repository, please refer to the dedicated documentation. Questions?We're on Gitter, https://gitter.im/jenkinsci/docker |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论