问题:
因此,我正在使用docker和jenkins(https://hub.docker.com/r/jenkinsci/blueocean/)在AWS上运行RHEL 7。
本文讨论了如何更改时区 https://wiki.jenkins.io/display/JENKINS/Change+time+zone
基本上两种方式
但是我已经通过这种方式为设置文件夹创建了一个卷
docker run -d -p 8080:8080 -v $PWD/jenkins:/var/jenkins_home:z -t jenkinsci/blueocean
这会使主目录为“ jenkins-blue”
目录列表为
4 -rw-r--r--. 1 <omitted user> 1647 Feb 27 17:00 config.xml
4 -rw-r--r--. 1 <omitted user> 3982 Feb 27 16:57 copy_reference_file.log
4 -rw-r--r--. 1 <omitted user> 966 Feb 27 17:04 credentials.xml
0 drwxr-xr-x. 3 <omitted user> 16 Feb 27 17:06 fingerprints
4 -rw-r--r--. 1 <omitted user> 156 Feb 27 16:57 hudson.model.UpdateCenter.xml
4 -rw-r--r--. 1 <omitted user> 1230 Feb 27 17:07 hudson.plugins.emailext.ExtendedEmailPublisher.xml
4 -rw-r--r--. 1 <omitted user> 370 Feb 27 16:58 hudson.plugins.git.GitTool.xml
4 -rw-------. 1 <omitted user> 1712 Feb 27 16:57 identity.key.enc
0 drwxr-xr-x. 2 <omitted user> 41 Feb 27 16:57 init.groovy.d
4 -rw-r--r--. 1 <omitted user> 94 Feb 27 16:58 jenkins.CLI.xml
4 -rw-r--r--. 1 <omitted user> 7 Feb 27 17:00 jenkins.install.InstallUtil.lastExecVersion
4 -rw-r--r--. 1 <omitted user> 7 Feb 27 17:00 jenkins.install.UpgradeWizard.state
4 -rw-r--r--. 1 <omitted user> 183 Feb 27 17:00 jenkins.model.JenkinsLocationConfiguration.xml
4 -rw-r--r--. 1 <omitted user> 171 Feb 27 16:57 jenkins.telemetry.Correlator.xml
0 drwxr-xr-x. 3 <omitted user> 18 Feb 27 17:00 jobs
0 drwxr-xr-x. 4 <omitted user> 37 Feb 27 16:58 logs
4 -rw-r--r--. 1 <omitted user> 907 Feb 27 16:58 nodeMonitors.xml
0 drwxr-xr-x. 2 <omitted user> 6 Feb 27 16:58 nodes
20 drwxr-xr-x. 106 <omitted user> 16384 Feb 27 16:59 plugins
4 -rw-r--r--. 1 <omitted user> 129 Feb 28 17:35 queue.xml
4 -rw-r--r--. 1 <omitted user> 64 Feb 27 16:57 secret.key
0 -rw-r--r--. 1 <omitted user> 0 Feb 27 16:57 secret.key.not-so-secret
4 drwx------. 4 <omitted user> 4096 Feb 27 17:14 secrets
0 drwxr-xr-x. 2 <omitted user> 182 Feb 27 16:59 updates
0 drwxr-xr-x. 2 <omitted user> 24 Feb 27 16:58 userContent
0 drwxr-xr-x. 3 <omitted user> 57 Feb 27 17:00 users
4 drwxr-xr-x. 11 <omitted user> 4096 Feb 27 16:57 war
0 drwxr-xr-x. 2 <omitted user> 6 Feb 27 16:58 workflow-libs
0 drwxr-xr-x. 4 <omitted user> 34 Feb 27 17:06 workspace
答案 0 :(得分:0)
在System Management -> Script command line
中运行它:
System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone',
'Asia/Shanghai')
https://wiki.jenkins.io/display/JENKINS/Change+time+zone
顺便说一句,我将其添加到我的定时任务中:
TZ=Asia/Shanghai
40 15 * * 1-5
OR
docker run ... -e JAVA_OPTS=-Duser.timezone=Asia/Shanghai
答案 1 :(得分:0)
您可以将 TZ 环境应用于您的docker-compose,如下所示:
image: jenkins/jenkins:alpine
container_name: jenkins
hostname: jenkins
restart: always
environment:
- TZ=Asia/Shanghai
volumes:
- ./jenkins/data:/var/jenkins_home
- ./jenkins/bin/jenkins.war:/usr/share/jenkins/jenkins.war
答案 2 :(得分:0)
FROM jenkins/jenkins:2.176.1
USER root
# Configure Timezone
RUN \
rm -f /etc/localtime && \
ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime && \
echo 'America/Los_Angeles' > /etc/timezone && \
dpkg-reconfigure --frontend noninteractive tzdata
答案 3 :(得分:0)
运行jenkins容器时只需映射卷
-v / etc / timezone:/ etc / timezone:ro
答案 4 :(得分:0)
环境: