Centos7部署jenkins.war并指定工作目录

一、下载jenkins.war文件

1、本文使用的2.3.45版本的jar

wget https://github.com/jenkinsci/jenkins/releases/download/jenkins-2.354/jenkins.war

2、 历史版本的war包

https://github.com/jenkinsci/jenkins/releases

二、java -jar启动(推荐)

1、java -jar启动方式

1、创建脚本

mkdir -vp /usr/local/software/jenkins/workspace
cd /usr/local/software/jenkins
#上传war包到/usr/local/software/jenkins目录下

2、制作脚本

#制作启动脚本[指定-DJENKINS_HOME的工作目录]
cat > /usr/local/software/jenkins/startJenkins.sh << EOF
chmod 777 jenkins.war
nohup java -DJENKINS_HOME=/usr/local/software/jenkins/workspace -jar jenkins.war  --httpPort=8085 >>log 2>&1 &
EOF

3、启动脚本

chmod 777 /usr/local/software/jenkins/startJenkins.sh
#启动脚本
sh startJenkins.sh

2、然后访问地址

http://ip:8085

3、其他相关命令 --help

[root@localhost jenkins_home]# java -jar jenkins.war --help
六月 20, 2023 1:52:42 下午 Main verifyJavaVersion
警告: You are running Jenkins on Java 1.8, support for which will end on or after June 21, 2022. This is earlier than a previously ann                                                                                                   ounced date. The Long Term Support (LTS) line of Jenkins will continue support till September 2022. Please refer to the documentation                                                                                                    for details on upgrading to Java 11: https://www.jenkins.io/redirect/upgrading-jenkins-java-version-8-to-11
Running from: /usr/local/docker/jenkins/jenkins_home/jenkins.war
webroot: $user.home/.jenkins
Jenkins Automation Server Engine 2.354
Usage: java -jar jenkins.war [--option=value] [--option=value]

Options:
   --webroot                = folder where the WAR file is expanded into. Default is ${JENKINS_HOME}/war
   --pluginroot             = folder where the plugin archives are expanded into. Default is ${JENKINS_HOME}/plugins
                              (NOTE: this option does not change the directory where the plugin archives are stored)
   --extractedFilesFolder   = folder where extracted files are to be located. Default is the temp folder
   --logfile                = redirect log messages to this file
   --enable-future-java     = allows running with new Java versions which are not fully supported (class version 52 and above)
   --javaHome               = Override the JAVA_HOME variable
   --toolsJar               = The location of tools.jar. Default is JAVA_HOME/lib/tools.jar
   --config                 = load configuration properties from here. Default is ./winstone.properties
   --prefix                 = add this prefix to all URLs (eg http://localhost:8080/prefix/resource). Default is none
   --commonLibFolder        = folder for additional jar files. Default is ./lib

   --extraLibFolder         = folder for additional jar files to add to Jetty classloader

   --logThrowingLineNo      = show the line no that logged the message (slow). Default is false
   --logThrowingThread      = show the thread that logged the message. Default is false
   --debug                  = set the level of debug msgs (1-9). Default is 5 (INFO level)

   --httpPort               = set the http listening port. -1 to disable, Default is 8080
   --httpListenAddress      = set the http listening address. Default is all interfaces
   --httpKeepAliveTimeout   = how long idle HTTP keep-alive connections are kept around (in ms; default 5000)?
   --httpsPort              = set the https listening port. -1 to disable, Default is disabled
   --httpsListenAddress     = set the https listening address. Default is all interfaces
   --httpsKeepAliveTimeout  = how long idle HTTPS keep-alive connections are kept around (in ms; default 5000)?
   --httpsKeyStore          = the location of the SSL KeyStore file. Default is ./winstone.ks
   --httpsKeyStorePassword  = the password for the SSL KeyStore file. Default is null
   --httpsKeyManagerType    = the SSL KeyManagerFactory type (eg SunX509, IbmX509). Default is SunX509
   --httpsPrivateKey        = this switch with --httpsCertificate can be used to run HTTPS with OpenSSL secret key
     / --httpsCertificate     file and the corresponding certificate file
   --httpsRedirectHttp      = redirect http requests to https (requires both --httpPort and --httpsPort)
   --http2Port              = set the http2 listening port. -1 to disable, Default is disabled
   --http2ListenAddress     = set the http2 listening address. Default is all interfaces
   --excludeCipherSuites    = set the ciphers to exclude (comma separated, use blank quote " " to exclude none) (default is
                           // Exclude weak / insecure ciphers
                           "^.*_(MD5|SHA|SHA1)$",
                           // Exclude ciphers that don't support forward secrecy
                           "^TLS_RSA_.*$",
                           // The following exclusions are present to cleanup known bad cipher
                           // suites that may be accidentally included via include patterns.
                           // The default enabled cipher list in Java will not include these
                           // (but they are available in the supported list).
                           "^SSL_.*$",
                           "^.*_NULL_.*$",
                           "^.*_anon_.*$"
   --controlPort            = set the shutdown/control port. -1 to disable, Default disabled

   --useJasper              = enable jasper JSP handling (true/false). Default is false
   --sessionTimeout         = set the http session timeout value in minutes. Default to what webapp specifies, and then to 60 minutes
   --sessionEviction        = set the session eviction timeout for idle sessions in seconds. Default value is 180. -1 never evict, 0 e                                                                                                   vict on exit
   --mimeTypes=ARG          = define additional MIME type mappings. ARG would be EXT=MIMETYPE:EXT=MIMETYPE:...
                              (e.g., xls=application/vnd.ms-excel:wmf=application/x-msmetafile)
   --requestHeaderSize=N    = set the maximum size in bytes of the request header. Default is 8192.
   --maxParamCount=N        = set the max number of parameters allowed in a form submission to protect
                              against hash DoS attack (oCERT #2011-003). Default is 10000.
   --useJmx                 = Enable Jetty Jmx
   --qtpMaxThreadsCount     = max threads number when using Jetty Queued Thread Pool
   --jettyAcceptorsCount    = Jetty Acceptors number
   --jettySelectorsCount    = Jetty Selectors number
   --usage / --help         = show this message
 Security options:
   --realmClassName               = Set the realm class to use for user authentication. Defaults to ArgumentsRealm class

   --argumentsRealm.passwd.<user> = Password for user <user>. Only valid for the ArgumentsRealm realm class
   --argumentsRealm.roles.<user>  = Roles for user <user> (comma separated). Only valid for the ArgumentsRealm realm class

   --fileRealm.configFile         = File containing users/passwds/roles. Only valid for the FileRealm realm class

 Access logging:
   --accessLoggerClassName        = Set the access logger class to use for user authentication. Defaults to disabled
   --simpleAccessLogger.format    = The log format to use. Supports combined/common/resin/custom (SimpleAccessLogger only)
   --simpleAccessLogger.file      = The location pattern for the log file(SimpleAccessLogger only)

三、tomcat启动

1、准备部署jenkins的tomcat

提前搭建tomcatcentos搭建tomcat

# 然后再tomcat下部署该项目
cd /usr/local/software/tomcat
#保证tomcat目录下有下载的tomcat
\cp -R apache-tomcat-8.5.81 tomcat8080Jenkins
# 复制jenkins启动的tomcat
mkdir -vp /usr/local/software/tomcat/tomcat8Jenkins

2、准备jenkins.war文件

#创建jenkins的war包源文件
mkdir -vp /usr/local/software/jenkins
cd /usr/local/software/jenkins
#下载war包(默认下载下来就是jenkins.war包)
wget https://github.com/jenkinsci/jenkins/releases/download/jenkins-2.354/jenkins.war

3、复制到tomcat中并启动

#jenkins.war包放到tomcat的webapps目录下
\cp -R jenkins-2.354.war /usr/local/software/tomcat/tomcat8080Jenkins/webapps/
#此处的jenkins-2.354.war是本人备份一个版本,下载下来是不带版本号的
mv jenkins-2.354.war jenkins.war
cd /usr/local/software/tomcat/tomcat8080Jenkins/bin
#接着上面地三步所在的目录下执行命令
nohup sh ./startup.sh &

4、默认路径(没有指定的情况下)

cat /root/.jenkins/secrets/initialAdminPassword
  • war包部署后默认的jenkins的路径信息
    1、jenkins的默认根路径/data/jenkins_home
    2、/root/.jenkins

四、访问地址栏

http://ip:port/jenkins

五、有可能访问不同是因为没有开放端口号

firewall-cmd --zone=public --add-port=8080/tcp --permanent && firewall-cmd --reload

六 WARNING o.k.stapler.jelly.AdjunctTag#doTag: AdjunctManager is not installed for this application. Skipping tags java.lang.Exception

解决办法,安装此次插件即可解决问题

yum install fontconfig -y
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值