从战争文件更新詹金斯


91

我有一台装有Ubuntu 12.04的计算机,并且已经安装了Jenkins ver。1.424.6根据本指南使用apt-get ,但是有一个新版本:

New version of Jenkins (1.447.2) is available for download (changelog).

如果按下载,我会得到一个jenkins.war文件...但是如何使用它来升级当前安装?还是在apt存储库更新之前不可能?

Answers:


161

您可以jenkins.war使用新文件覆盖现有文件,然后重新启动Jenkins。

该文件通常位于中/usr/share/jenkins

如果您的系统不是这种情况,在中Manage Jenkins -> System Information,它将.war在下显示文件的路径executable-war


16
在我的机器上,它位于/ usr / share / jenkins /中。复制并通过“ service jenkins restart”重新启动后,它仍然显示旧版本并建议更新-我在做什么错?
u123 2012年

2
升级后配置文件的一致性如何?您是否需要重新设置整个过程?它们是否支持向后兼容?
Denys S.

@DEnysS。它会保留所有配置。我删除了现有的war文件,并将新的war文件从Downloads移至/ usr / share / jenkins,它运行良好。(Aptitude并未显示jenkins的更新)
惠特尼·

+1这对我很有帮助,因为Ubuntu的当前版本是1.6,战争版本是2.4。它在外观和插件可用性方面存在巨大差异。因此,这极大地帮助了我。担心我必须安装tomcat并以困难的方式进行安装。
Caperneoignis '16

1
@bcmcfc的答案一步一步在这里:stackoverflow.com/a/46733405/1404135
3z33etm 17-10-13

32

如果您已经通过apt-get安装了Jenkins,则还应该通过apt-get更新Jenkins,以避免将来出现问题。更新应该通过“ apt-get update”然后“ apt-get upgrade”进行。

有关详细信息,请访问以下URL:

https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu


13
+1 b / c,您将永远不知道Ubuntu在Jenkins配置方面发生了什么变化。补充说明pkg.jenkins-ci.org/debian提供了可从项目直接通过apt-get安装的更新软件包。
mabi 2012年

如果执行上述操作,则无需从war文件更新jenkins。我认为这是在Ubuntu上更好的方法。
Ripon Al Wasim

10
如果以前安装与詹金斯易于得到,但通过Ubuntu默认的软件包安装位置(即没有pkg.jenkins-ci.org/debian),您必须安装新的人之前先删除默认的Ubuntu的软件包sudo apt-get remove jenkins jenkins-common,然后sudo apt-get install jenkins。如果您不这样做,更新将在trying to overwrite '/usr/share/jenkins/jenkins.war', which is also in package jenkins-common 1.424.6+dfsg-1ubuntu0.1
Matthieu Rouget

30
#on ubuntu, in /usr/share/jenkins:

sudo service jenkins stop
sudo mv jenkins.war jenkins.war.old
sudo wget https://updates.jenkins-ci.org/latest/jenkins.war
sudo service jenkins start

1
大!最后稳定的联系也非常有用:updates.jenkins-ci.org/stable/latest/jenkins.war
ℛɑƒæĿᴿᴹᴿ

最佳实践,容易做到。感谢您的回答
Jinna Balu

!您通过詹金斯(Jenkins)在半夜心脏病发作帮助我,迫使我们升级并且不运行任何插件
Emjey

12
apt-get更新
apt-get升级 

到目前为止,最简单的在linux上升级的方法,每次都像一个魅力。


顺便说一句在CentOS上yum update jenkins应该这样做。
Nagev

4

尽管我认为这不是对OP问题的有效答案,但我仍要强调,在Ubuntu上部署Jenkins(以及可能的大多数(即使不是全部)库/软件包/软件)的最佳方法是利用能力(或apt-获取)管理系统。

此处记录了该文件:https : //wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu(请注意,如果您想使用LTS构建,请点击此仓库http:// pkg。 jenkins-ci.org/debian-stable/

因此,如果您确实有机会使用此方法,则只需 apt-get upgrade jenkins


从理论上讲,您是对的,但是从库存安装升级时这是行不通的。安装最新的软件包后,它正在启动,但显示503错误。我遵循此处编写的过程,并且必须应用Matthieu Rouget的解决方案才能获得一致的pkg状态。
Glenn Plas 2014年

3

当您打开Jenkins面板时,它将显示最新版本的可用软件包。您可以通过服务器中的wget命令下载它。下载最新的软件包后,您应该获取.war备份文件。

例如:wget http://updates.jenkins-ci.org/download/war/2.205/jenkins.war

Ubuntu的Jenkins war文件路径-/ usr / share / jenkins /

centos的Jenkins war文件路径-/ usr / lib / jenkins /

进行备份后,覆盖war文件并重新启动jenkins服务。

Ubuntu-服务jenkins重新启动,centos-systemctl重新启动jenkins.service


2

我们使用以下命令从.war文件运行jenkins。

java -Xmx2500M -jar jenkins.war --httpPort=3333 --prefix=/jenkins

您甚至可以从〜/ Downloads目录运行命令


2

我用这个时髦的脚本来下载新的战争文件

import java.util.concurrent.atomic.AtomicInteger

class ThreadHelper{
    static done = false;
    static starttime = System.currentTimeMillis()
    static synchronized printx (message) {    printf ("%5s seconds: %20s",(System.currentTimeMillis()-starttime)/1000.0 , message); println("") }
    def download(address)
    {
    def filename = new File(System.getenv()['CI_HOME'] + '/' + address.tokenize("/")[-1])
    println(filename.getCanonicalPath())
    def file = new FileOutputStream(filename)
    def out = new BufferedOutputStream(file)
    out << new URL(address).openStream()
    out.close()
    done=true;
    }

}

println("executing from ... "+ new File(".").getCanonicalPath())

def counter = new AtomicInteger();
    th = Thread.start {
    while(!ThreadHelper.done) {
    sleep 1000
    counter.incrementAndGet()
    print '.'
    }
}

th2 = Thread.start { new ThreadHelper().download("http://mirrors.jenkins-ci.org/war/latest/jenkins.war") }
th.join()
th2.join()

ThreadHelper.printx('done')

另一个脚本关闭了tomcat-复制战争并重新启动

我们将其托管在Windows 2008和tomcat上,我使用sc查询,sc config,sc stop和sc start来管理Windows服务

    set warname=jenkins

if '%name%' == 'trak' set warname=trak

pushd .
if '%name%'=='' goto badname
if '%warname%'=='' goto badname

if '%ci_home%'=='' goto badcihome

REM =====================================================
REM stop windows service
sc stop %name%

REM sleep for 5 seconds see http:\\stackoverflow.com\questions\1672338\how-to-sleep-for-5-seconds-in-windowss-command-prompt-or-dos
ping 1.1.1.1 -n 1 -w 3000 > nul

rem replace forward slash with backward slash
set tomcat_dir=%ci_home:/=\%\instances\tomcat7-%name%

REM Create sub directory called bak-yymmdd-hhmmss
REM where yymmdd-hhmmss is a date-time stamp like 120601-142907

set hh=%time:~0,2%

REM Since there is no leading zero for times before 10 am, have to put in
REM a zero when this is run before 10 am.

if "%time:~0,1%"==" " set hh=0%hh:~1,1%

set yymmdd_hhmmss=%date:~12,2%%date:~4,2%%date:~7,2%-%hh%%time:~3,2%%time:~6,2%

set backupdir=bak-%yymmdd_hhmmss%

REM =====================================================
md %tomcat_dir%\logs\%backupdir%

cd %tomcat_dir%\logs

dir bak*
echo "nothing-to-log" >> force.log

REM move command will fail if there is nothing to move hence the force log statement above

call move *.* %backupdir%

REM =====================================================
rmdir %tomcat_dir%\webapps\%name% /q/s

echo f|xcopy %ci_home%\%warname%.war %tomcat_dir%\webapps\%name%.war /y

REM TODO===== something about jenkins plugins

REM =====================================================
cd "%tomcat_dir%\bin"
call catalina version

echo =====================================================
echo ====== removing %name%
call service remove %name%

echo =====================================================
echo ====== installing %name%
call service install %name%

echo on

REM setting service to start automatically, note that space before the word auto IS REQUIRED
sc config %name% start= auto

REM =====================================================
sc start %name%

popd

exit 0

goto done

:badname
echo 'name required - this will be used as windows service name as well'
pause
exit 1

:badcihome
echo 'CI home env var required - ci_home'
pause
exit 1

:done

2
https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+on+Ubuntu

Once installed like this, you can update to the later version of Jenkins (when it comes out) by running the following commands:
-------
sudo apt-get update
sudo apt-get install jenkins
-------
(aptitude or apt-get doesn't make any difference.)
What does this package do?
Jenkins will be launched as a daemon up on start. See /etc/init.d/jenkins for more details.
The 'jenkins' user is created to run this service.
Log file will be placed in /var/log/jenkins/jenkins.log. Check this file if you are troubleshooting Jenkins.
/etc/default/jenkins will capture configuration parameters for the launch like e.g JENKINS_HOME
By default, Jenkins listen on port 8080. Access this port with your browser to start configuration.

1

我的是安装在/ usr / share / jenkins下的,我以为它是通过apt-get安装的,所以也可能要检查一下。

Ubuntu 12.04.1



1

要升级Jenkins WAR文件,请执行以下步骤:

  • 使用以下命令停止Jenkins服务器: systemctl stop jenkins
  • 前往詹金斯战争地点:例如: /usr/lib/jenkins
  • 从jenkins.war备份: mv jenkins.war jenkins.war_bkp
  • 使用wget或curl命令下载Jenkins: wget http://updates.jenkinsci.org/download/war/(version)/jenkins.war
  • 使用以下命令启动Jenkins服务器: systemctl start jenkins
  • 使用以下命令检查Jenkins服务器状态: systemctl status jenkin
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.