問題描述
我有一台Ubuntu 12.04的機器,並安裝了Jenkins ver。 1.424.6使用基於this guide的apt-get,但有一個新版本:
New version of Jenkins (1.447.2) is available for download (changelog).
如果我按下載,我會得到一個jenkins.war文件……但是如何使用它來升級我當前的安裝呢?或者在apt存儲庫更新之前是不可能的?
最佳解決思路
您可以使用新的jenkins.war
文件覆蓋現有的jenkins.war
文件,然後重新啟動Jenkins。
該文件通常位於/usr/share/jenkins
中。
如果您的係統不是這種情況,則在Manage Jenkins -> System Information
中,它將顯示executable-war
下.war
文件的路徑。
次佳解決思路
如果您已通過apt-get安裝了Jenkins,則還應通過apt-get更新Jenkins以避免將來出現問題。更新應通過“apt-get更新”,然後“apt-get升級”。
有關詳細信息,請訪問以下URL:
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
第三種解決思路
#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
第四種思路
apt-get update
apt-get upgrade
到目前為止,最簡單的Linux升級方式,每次都像魅力一樣。
第五種思路
雖然我不認為這是OP問題的有效答案,但我仍然強調在Ubuntu上部署Jenkins(可能是大多數(如果不是全部)庫/軟件包/軟件)的最佳方法是利用aptitude(或apt-get)管理係統。
這裏記錄:https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu(請注意,如果你想使用LTS構建,請點擊此repo http://pkg.jenkins-ci.org/debian-stable/)
因此,如果你真的使用這種方法,你隻需要做一個apt-get upgrade jenkins
第六種思路
我們使用以下命令從.war文件運行jenkins。
java -Xmx2500M -jar jenkins.war --httpPort=3333 --prefix=/jenkins
您甚至可以從〜/Downloads目錄運行命令
第七種思路
我使用這個groovy腳本下載新的war文件
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
第八種思路
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.