有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Jenkins在Jenkins运行时没有运行。战争没有爆发

我正在尝试为我正在从事的selenium/maven项目自动安排Jenkins的工作。一切都正常运行,自动调度只有在。jar文件正在运行(使用命令:java -jar jenkins.war --httpPort=8089)。但一旦我退出命令提示符和Jenkins服务器,它就根本不会运行。我的假设是,无论连接与否,无论计算机是否登录,它都应该运行

在我看来,当詹金斯夫妇去世时,詹金斯的自动计程系统似乎不工作了。war文件未启动并运行

我错过什么了吗


共 (1) 个答案

  1. # 1 楼答案

    如果未执行.war文件,则整个jenkins进程将不会运行。问题是你如何管理詹金斯

    这里有extensive documentation如何运行它。然而,我最终在一个支持systemd的操作系统(linux)上运行,它有一个system.d服务文件:/usr/lib/systemd/system/jenkins.service

    [Unit]
    Description=Jenkins
    Documentation=https://wiki.jenkins.io/display/JENKINS/Use+Jenkins
    After=network.target
    Requires=network.target
    
    [Service]
    Type=simple
    EnvironmentFile=/etc/default/jenkins
    ExecStart=/home/jenkins/jdk/jdk1.8.0_121/bin/java -Xmx2048m -Xms1024m -DJENKINS_HOME=/home/jenkins -jar /home/jenkins/jenkins.war  javaHome=/home/jenkins/jdk/jdk1.8.0_121  httpPort=8080  webroot=/var/cache/jenkins/war  ajp13Port=-1  debug=5  handlerCountMax=100  handlerCountMaxIdle=20
    # Restart=always
    # RestartSec=120
    User=jenkins
    
    [Install]
    WantedBy=multi-user.target
    

    与:/etc/default/jenkins

    # Managed manually
    JENKINS_HOME="/home/jenkins"
    #JENKINS_LOGFILE="/home/jenkins/jenkins.log"
    
    # TODO: manage JAVA_HOME through java-alternatives
    JAVA_HOME="/home/jenkins/jdk/jdk1.8.0_121"
    JAVA_OPTIONS="-Xmx2048m -Xms1024m"
    
    # Web Configuration
    HTTP_WEB_ROOT="/var/cache/jenkins/war"
    HTTP_PORT="8080"
    HTTP_LISTEN_ADDRESS="0.0.0.0"
    
    # Jenkins Configurations
    #   more: https://wiki.jenkins.io/display/JENKINS/Starting+and+Accessing+Jenkins
    JENKINS_ARGS=" ajp13Port=-1  debug=5  handlerCountMax=100  handlerCountMaxIdle=20"
    
    $ systemctl status jenkins
    ● jenkins.service - Jenkins
       Loaded: loaded (/usr/lib/systemd/system/jenkins.service; linked; vendor preset: disabled)
       Active: active (running) since Wed 2021-03-31 10:08:36 EDT; 1 weeks 1 days ago
         Docs: https://wiki.jenkins.io/display/JENKINS/Use+Jenkins
     Main PID: 27219 (java)
        Tasks: 70 (limit: 512)
       CGroup: /system.slice/jenkins.service
               └─27219 /home/jenkins/jdk/jdk1.8.0_121/bin/java -Xmx2048m -Xms1024m
    

    并通过Apache HTTP服务器,通过ProxyPath发布:

    $ systemctl status apache
    ● apache2.service - The Apache Webserver
       Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled)
       Active: active (running) since Tue 2021-02-02 12:34:05 EST; 2 months 4 days ago
      Process: 30426 ExecReload=/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k graceful (code=exited, status=0/SUCCESS)
     Main PID: 18524 (httpd-prefork)
       Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
        Tasks: 11
       CGroup: /system.slice/apache2.service
    

    使用Apache HTTP虚拟主机配置:

    <IfDefine SSL>
    <IfDefine !NOSSL>
    
    ##
    ## SSL Virtual Host Context
    ##
    
    <VirtualHost _default_:443>
    
      ProxyPass         /  http://localhost:8080/ nocanon
      ProxyPassReverse  /  http://localhost:8080/
    
      # ProxyRequests     Off
      ProxyPreserveHost On
      AllowEncodedSlashes NoDecode
    
      <Proxy http://localhost:8080/*>
        Require all granted
      </Proxy>
    
      # ProxyPassMatch  ^/(?\!.well-known)  http://localhost:8080 nocanon
    
      ErrorLog /var/log/apache2/error_log
      TransferLog /var/log/apache2/access_log
    
      #   SSL Engine Switch:
      #   Enable/Disable SSL for this virtual host.
      SSLEngine on
    
      #   You can use per vhost certificates if SNI is supported.
      SSLCertificateFile /etc/apache2/ssl.crt/<your-server>.com.crt
      SSLCertificateKeyFile /etc/apache2/ssl.key/<your-server>.com.key
    
      CustomLog /var/log/apache2/ssl_request_log   ssl_combined
    
    </VirtualHost>
    
    </IfDefine>
    </IfDefine>
    

    相同的配置设置,但通过NGINX:Jenkins reverse-proxy configuration nginx

    通过这种方式,您可以管理jenkins服务器(启动/停止)和TLS(SSL)通信:

    systemctl status jenkins nginx
    

    如果你通过Docker运行Jenkins,你不需要在Jenkins前面公开另一个Web服务器(例如Apache/NGINX),你不会公开Jenkins Docker容器,但你前面可能有一个Kubernetes/(a)LB。不建议公开揭露詹金斯

    Web服务器为您提供了在Jenkins面前使用缓存或CDN的灵活性,尤其是当您使用发布工件功能时