【Jenkins】windows安装步骤

【Jenkins】windows安装步骤

官网

  • 官网: https://www.jenkins.io/
  • windows下载地址: https://www.jenkins.io/download/thank-you-downloading-windows-installer/
  • 通用包下载,点击Generic Java package (.war):
    • https://mirrors.tuna.tsinghua.edu.cn/jenkins/war-stable/2.387.1/jenkins.war
    • https://mirror.twds.com.tw/jenkins/war-stable/2.462.3/jenkins.war
  • Jenkins安装软硬件要求: https://www.jenkins.io/doc/book/installing/linux/#prerequisites
    • Java版本要求: https://www.jenkins.io/doc/book/platform-information/support-policy-java/
  • 官方用户指南: https://www.jenkins.io/doc/
  • jenkins.io如果官网访问不了,尝试修改DNS114.114.114.1148.8.8.8

使用WAR包方式运行

  • 新建一个安装目录,例如D:\ProgramFiles\Jenkins
  • jenkins.war复制到安装目录
  • 新建环境变量: JENKINS_HOME=D:\ProgramFiles\Jenkins
    解压的war包默认是放在C盘的用户目录,通过JENKINS_HOME环境变量可以快捷指定解压的WAR包路径、插件路径、日志路径等
  • 查看帮助: java -jar jenkins.war --help
shell 复制代码
Microsoft Windows [版本 10.0.22631.4317]
(c) Microsoft Corporation。保留所有权利。

D:\ProgramFiles\Jenkins>java -jar jenkins.war --help
Running from: D:\ProgramFiles\Jenkins\jenkins.war
webroot: D:\ProgramFiles\Jenkins\war
Jenkins Automation Server Engine 2.462.3
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
   --enable-future-java     = allows running with Java versions which are not fully supported
   --paramsFromStdIn        = Read parameters from standard input (stdin)
   --version                = Print version to standard output (stdout) and exit
   --javaHome               = Override the JAVA_HOME variable
   --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

   --logfile                = redirect log messages to this file
   --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 Winstone 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
   --httpUnixDomainPath     = set the http unix domain path. Default is no path
   --httpKeepAliveTimeout   = how long idle HTTP keep-alive connections are kept around (in ms; default 30000)?
   --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 30000)?
   --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
   --httpsRedirectHttp      = redirect http requests to https (requires both --httpPort and --httpsPort)
   --http2Port              = set the http2 listening port. -1 to disable, Default is disabled
   --httpsSniHostCheck      = if the SNI Host name must match when there is an SNI certificate. Check disabled per default
   --httpsSniRequired       = if a SNI certificate is required. Disabled per default
   --http2ListenAddress     = set the http2 listening address. Default is all interfaces
   --httpsVerifyClient      = if the client needs a certificate. Can be true (clients always needs a certificate),
                              optional or false.
   --excludeProtocols       = set protocol versions to exclude. (comma separated list, use blank quote " " to exclude none)
                              (default is "SSL", "SSLv2", "SSLv2Hello", "SSLv3")
   --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

   --compression            = set the compression scheme (gzip or none to disable compression). Default is gzip.
   --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 evict 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.
   --responseHeaderSize=N    = set the maximum size in bytes of the response 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)
  • 指定端口启动Jenkins: java -jar jenkins.war --httpPort=8890
shell 复制代码
D:\ProgramFiles\Jenkins>java -jar jenkins.war --httpPort=8890
Running from: D:\ProgramFiles\Jenkins\jenkins.war
webroot: D:\ProgramFiles\Jenkins\war
2024-10-11 01:27:24.897+0000 [id=1]     INFO    winstone.Logger#logInternal: Beginning extraction from war file
2024-10-11 01:27:25.753+0000 [id=1]     WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2024-10-11 01:27:25.813+0000 [id=1]     INFO    org.eclipse.jetty.server.Server#doStart: jetty-10.0.24; built: 2024-08-26T17:58:21.070Z; git: d5384207795da96fad32db8ea8d26b69955bcc03; jvm 21+35-2513
2024-10-11 01:27:32.225+0000 [id=1]     INFO    o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2024-10-11 01:27:32.276+0000 [id=1]     INFO    o.e.j.s.s.DefaultSessionIdManager#doStart: Session workerName=node0
2024-10-11 01:27:33.699+0000 [id=1]     INFO    hudson.WebAppMain#contextInitialized: Jenkins home directory: D:\ProgramFiles\Jenkins found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
2024-10-11 01:27:34.326+0000 [id=1]     INFO    o.e.j.s.handler.ContextHandler#doStart: Started w.@7ea08277{Jenkins v2.462.3,/,file:///D:/ProgramFiles/Jenkins/war/,AVAILABLE}{D:\ProgramFiles\Jenkins\war}
2024-10-11 01:27:34.451+0000 [id=1]     INFO    o.e.j.server.AbstractConnector#doStart: Started ServerConnector@2e48362c{HTTP/1.1, (http/1.1)}{0.0.0.0:8890}
2024-10-11 01:27:34.796+0000 [id=1]     INFO    org.eclipse.jetty.server.Server#doStart: Started Server@14fc1f0{STARTING}[10.0.24,sto=0] @10278ms
2024-10-11 01:27:34.796+0000 [id=69]    INFO    winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
2024-10-11 01:27:34.952+0000 [id=78]    INFO    jenkins.InitReactorRunner$1#onAttained: Started initialization
2024-10-11 01:27:34.999+0000 [id=98]    INFO    jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2024-10-11 01:27:37.490+0000 [id=106]   INFO    jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2024-10-11 01:27:37.521+0000 [id=116]   INFO    jenkins.InitReactorRunner$1#onAttained: Started all plugins
2024-10-11 01:27:37.540+0000 [id=119]   INFO    jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2024-10-11 01:27:38.148+0000 [id=119]   INFO    jenkins.InitReactorRunner$1#onAttained: System config loaded
2024-10-11 01:27:38.148+0000 [id=119]   INFO    jenkins.InitReactorRunner$1#onAttained: System config adapted
2024-10-11 01:27:38.148+0000 [id=92]    INFO    jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
2024-10-11 01:27:38.163+0000 [id=92]    INFO    jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
2024-10-11 01:27:38.226+0000 [id=136]   INFO    hudson.util.Retrier#start: Attempt #1 to do the action check updates server
2024-10-11 01:27:39.150+0000 [id=107]   INFO    jenkins.install.SetupWizard#init:

*************************************************************
*************************************************************
*************************************************************

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

562cc0d6bc444f299ef44f79460f4589

This may also be found at: D:\ProgramFiles\Jenkins\secrets\initialAdminPassword

*************************************************************
*************************************************************
*************************************************************

2024-10-11 01:27:47.879+0000 [id=136]   INFO    h.m.DownloadService$Downloadable#load: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
2024-10-11 01:27:47.879+0000 [id=136]   INFO    hudson.util.Retrier#start: Performed the action check updates server successfully at the attempt #1
2024-10-11 01:27:51.060+0000 [id=107]   INFO    jenkins.InitReactorRunner$1#onAttained: Completed initialization
2024-10-11 01:27:51.060+0000 [id=58]    INFO    hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up and running

Jenkins第一次启动,会在控制台打印管理员初始化密码,比如562cc0d6bc444f299ef44f79460f4589,同时jenkins目录下也生成了很多个文件夹

浏览器访问Jenkins

  • 访问http://localhost:8890
  • 输入密码562cc0d6bc444f299ef44f79460f4589,进入jenkins首页 如果忘记了或找不到启动时的初始密码,可以从这个位置查看初始密码: D:\ProgramFiles\Jenkins\secrets\initialAdminPassword
  • 选哪个都可以,我一般会选择选择插件来安装,可以看看默认勾选的是哪些插件
  • 根据需要勾选插件,然后点右下角的安装
  • 接下来就是等待Jenkins下载和安装上一步勾选的插件
  • 安装完插件后,会进入下一个页面,创建管理员账号
    也可以不创建用户,直接点击使用admin账户继续
  • 配置Jenkins访问地址
  • 这样就完成了Jenkins的基本配置
  • 成功进入Jenkins首页

windows-installer安装

除了WAR包方式,windows还可以下载installer安装程序进行安装

安装过程问题解决

This account either does not hava the privilege to logon as a service or the account was unable to be verified

  • 如果出现这个错误提示,则参考资料: https://blog.csdn.net/wuxiaoying888/article/details/124457546
  • 命令行输入secpol.msc打开本地安全策略
  • 本地策略 --> 用户权限分配 --> 作为服务登录 --> 添加当前登录用户

安装成功

会在windows服务列表中新增一个Jenkins服务

修改jenkins.xml

  • <env name="JENKINS_HOME" value="D:\ProgramFiles\Jenkins\.jenkins"/>
  • <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "D:\ProgramFiles\Jenkins\jenkins.war" --httpPort=8080 --webroot="D:\ProgramFiles\Jenkins\war"</arguments>
  • <pidfile>D:\ProgramFiles\Jenkins\jenkins.pid</pidfile>

启动jenkins

net start Jenkins

访问jenkins

  • 在浏览器输入http://localhost:8080
  • 打开D:\ProgramFiles\Jenkins\.jenkins\secrets\initialAdminPassword复制初始化密码
  • 安装社区推荐的插件
    • Folders
    • OWASP Markup Formatter
    • Build Timeout
    • Credentials Binding
    • Timestamper
    • Workspace Cleanup
    • Ant
    • Gradle
    • Pipeline
    • GitHub Branch Source
    • Pipeline: GitHub Groovy Libraries
    • Pipeline: Stage View
    • Git
    • SSH Build Agents
    • Matrix Authorization Strategy
    • PAM Authentication
    • LDAP
    • Email Extension
    • Mailer
    • Localization: Chinese (Simplified)
  • 跳过

安装插件

离线安装插件

  • D:\ProgramFiles\Jenkins\.jenkins\plugins直接将jpi放入Jenkinsplugins文件夹下,然后重启Jenkins即可
  • 重启Jenkins,在浏览器输入http://localhost:8080/restart

常用插件

  • Git: https://plugins.jenkins.io/git/#releases
  • Subversion: https://plugins.jenkins.io/subversion/#releases
  • Gitee: https://plugins.jenkins.io/gitee/#releases
  • Pipeline: https://plugins.jenkins.io/workflow-aggregator/#releases
    Pipeline还依赖下面这几个插件
    • Pipeline: Stage View
    • Pipeline: Nodes and Processes
    • Pipeline: Basic Steps
  • Localization: Chinese (Simplified)
  • Publish Over SSH: https://plugins.jenkins.io/publish-over-ssh/#releases

常用Jenkins页面

  • Jenkins环境变量: http://localhost:8080/env-vars.html/
  • 全局变量: http://localhost:8080/job/ssh-test/pipeline-syntax/globals
  • Pipeline语法生成器: http://localhost:8080/job/ssh-test/pipeline-syntax/
相关推荐
梓仁沐白21 分钟前
ubuntu+windows双系统切换后蓝牙设备无法连接
windows·ubuntu
九鼎科技-Leo4 小时前
什么是 WPF 中的依赖属性?有什么作用?
windows·c#·.net·wpf
朝九晚五ฺ5 小时前
【Linux探索学习】第十四弹——进程优先级:深入理解操作系统中的进程优先级
linux·运维·学习
Kkooe6 小时前
GitLab|数据迁移
运维·服务器·git
久醉不在酒6 小时前
MySQL数据库运维及集群搭建
运维·数据库·mysql
Yang.997 小时前
基于Windows系统用C++做一个点名工具
c++·windows·sql·visual studio code·sqlite3
我不瘦但很逗7 小时前
Windows下使用DBeaver连接云数据库(MySQL)
数据库·windows
虚拟网络工程师8 小时前
【网络系统管理】Centos7——配置主从mariadb服务器案例(下半部分)
运维·服务器·网络·数据库·mariadb
BLEACH-heiqiyihu8 小时前
RedHat7—Linux中kickstart自动安装脚本制作
linux·运维·服务器
ashane13148 小时前
Java list
java·windows·list