Jenkins安装及配置(Windows)

Jenkins安装及配置(Windows)

1、下载安装包 jenkins.msi

前置条件:需要安装JDK8或JDK11

下载地址:https://www.jenkins.io/download/

2、安装步骤

3、安装完成之后,Jenkins服务无法启动。查看安装目录下的日志文件jenkins.err.log,发现是jdk版本不匹配。

Jenkins requires Java versions [8, 11] but you are running with Java 17 from D:\java\jdk-17.0.2
java.lang.UnsupportedClassVersionError: 61.0
  at Main.verifyJavaVersion(Main.java:137)
  at Main.main(Main.java:105)
2月 05, 2022 6:39:03 下午 Main verifyJavaVersion
严重: Running with Java class version 61 which is not in the list of supported versions: [52, 55]. Run with the --enable-future-java flag to enable such behavior. See https://jenkins.io/redirect/java-support/
java.lang.UnsupportedClassVersionError: 61.0
  at Main.verifyJavaVersion(Main.java:137)
  at Main.main(Main.java:105)

Jenkins requires Java versions [8, 11] but you are running with Java 17 from D:\java\jdk-17.0.2
java.lang.UnsupportedClassVersionError: 61.0
  at Main.verifyJavaVersion(Main.java:137)
  at Main.main(Main.java:105)

 

下载一个jdk11。https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html

修改jenkins.xml文件里的jdk路径<executable>D:\java\jdk-11.0.13\bin\java.exe</executable>。

<service>
  <id>jenkins</id>
  <name>Jenkins</name>
  <description>This service runs Jenkins automation server.</description>
  <env name="JENKINS_HOME" value="%ProgramData%\Jenkins\.jenkins"/>
  <!--
    if you'd like to run Jenkins with a specific version of Java, specify a full path to java.exe.
    The following value assumes that you have java in your PATH.
  -->
  <executable>D:\java\jdk-11.0.13\bin\java.exe</executable>
  <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "D:\program\Jenkins\jenkins.war" --httpPort=8080 --webroot="%ProgramData%\Jenkins\war"</arguments>
  <!--
    interactive flag causes the empty black Java window to be displayed.
    I'm still debugging this.
  <interactive />
  -->
  <logmode>rotate</logmode>

  <onfailure action="restart"/>
  
  <!-- 
    In the case WinSW gets terminated and leaks the process, we want to abort
    these runaway JAR processes on startup to prevent corruption of JENKINS_HOME.
    So this extension is enabled by default.
  -->
  <extensions>
    <!-- This is a sample configuration for the RunawayProcessKiller extension. -->
    <extension enabled="true" className="winsw.Plugins.RunawayProcessKiller.RunawayProcessKillerExtension" id="killOnStartup">
      <pidfile>%ProgramData%\Jenkins\jenkins.pid</pidfile>
      <stopTimeout>10000</stopTimeout>
      <stopParentFirst>false</stopParentFirst>
    </extension>
  </extensions>
  
  <!-- See the referenced examples for more options -->
  
</service>

重新启动服务

4、访问web控制台进行配置。

http://localhost:8080

C:\ProgramData\Jenkins\.jenkins\secrets\initialAdminPassword

选择“安装推荐的插件”即可。

5、添加用户和管理权限。配置Jenkins权限,添加管理员账户。

点击 左侧的 Manage Jenkins—>Configure Global Security 进入如下界面:

a.在安全域中,选择“Jenkins’ own user database” ,并勾选 “允许用户注册”。
b.在授权策略中,选择 “安全矩阵”,单击“add user”按钮,输入admin,点击“确定”按钮,可以看到用户admin被添加到“用户/组”表格中。
c.在“用户/组”表格中,给admin选择所有权限。

发表回复

您的电子邮箱地址不会被公开。