Jenkins : Session Timeout After 60 Seconds – Caused by Current Login Plugin

RojerChen.2025.05.06

不知道曾幾何時開始,Jenkins 使用到一半常常就莫名登出,最困擾的莫過於寫 pipeline 的時候,都要先複製現在撰寫的內容,避免因為 session timeout 而沒有存檔到。剛好趁著最近要升級 Jenkins 順便來解決這個困擾已久的問題。

一開始我以為應該只是改改某個設定檔就好,沒想到 ChatGPT 問了老半天,一直找不到問題所在,直到最後才發現到是某個 plugin 所造成的。

Jenkins Session Timeout

我測試 session timeout 是使用下面這段語法來測試的。

def session = org.kohsuke.stapler.Stapler.getCurrentRequest().getSession(false) 
println "Session timeout: ${session.getMaxInactiveInterval()} seconds"

測試後的結果如下 60 seconds

Jenkins Script Console
整個資料夾沒有任何一個檔案跟 60 seconds 有關聯,並且我怎樣設定 jenkins.xml 都沒有效果。

實際上出問題的是這個檔案,hudson.plugins.concurrent_login.UserInfoProperty.xml 內容如下
<?xml version='1.1' encoding='UTF-8'?>
<hudson.plugins.concurrent__login.UserInfoProperty_-DescriptorImpl 
plugin="concurrent-login-plugin@0.7">
  <useConcurrentLogin>true</useConcurrentLogin>
</hudson.plugins.concurrent__login.UserInfoProperty_-DescriptorImpl>

Jenkins Current Login Plugin

根據 ChatGPT 的描述如下

  • 這個 plugin 會干涉 Jenkins 的 session 機制,特別是用來避免帳號多重登入。
  • 在啟用時,它可能強制將 session timeout 設定為某個內定值,例如 60 秒,以防止帳號掛太久。
  • Plugin 版本是 0.7,非常老舊,最後一次更新是 2014 年左右,跟你現在用的 Jenkins 2.5.x 根本不同時代,很可能會引發不相容或 bug。

由於我的 Jenkins 環境是從舊版往上升級的,裡面夾雜了不少舊的檔案,經過反覆的測試才找到罪魁禍首的檔案, 根據 ChatGPT 的建議 hudson.plugins 已經不支援現在的版本了,有些用不到的項目都可以移除掉了。

    Blogger Comment

0 意見: