Jenkins 部署
?
1? 修改jenkins的根目錄,默認(rèn)地在C:\Documents and Settings\AAA\.jenkins 。
.jenkins
├─jobs
│? └─JavaHelloWorld
│????? ├─builds
│????? │? ├─2011-11-03_16-48-17
│????? │? ├─2011-11-03_16-49-05
│????? │? ├─2011-11-03_16-49-29
│????? │? ├─2011-11-03_17-01-49
│????? │? └─2011-11-03_17-11-42
│????? └─workspace
│????????? ├─build
│????????? │? ├─classes
│????????? │? │? └─oata
│????????? │? └─jar
│????????? └─src
│????????????? └─oata
├─plugins
├─usercontent
├─war
?
可以通過(guò)設(shè)置環(huán)境變量來(lái)修改,例如:
set JENKINS_HOME=C:\jenkins
然后重新啟動(dòng)jenkins。
?
2? 備份和恢復(fù)jenkins
?只需要備份JENKINS_HOME下的所有文件和文件夾,恢復(fù)的時(shí)候需要先停止jenkins。
?
3 移動(dòng),刪除或修改jobs
對(duì)于移動(dòng)或刪除jobs,只需要簡(jiǎn)單地移動(dòng)或刪除%JENKINS_HOEM%\jobs目錄。
對(duì)于修改jobs的名字,只需要簡(jiǎn)單地修改%JENKINS_HOEM%\jobs下對(duì)應(yīng)job的文件夾的名字。
對(duì)于不經(jīng)常使用的job,只需要對(duì)%JENKINS_HOEM%\jobs下對(duì)應(yīng)的jobs的目錄zip或tar后存儲(chǔ)到其他的地方。
?
4 可以在jenkins的url中執(zhí)行一些命令來(lái)操作jenkins,如下
http://[jenkins-server]/[command] 命令可以為:
exit shutdown jenkins
restart restart jenkins
reload to reload the configuration
5 Jenkins 啟動(dòng)時(shí)的命令行參數(shù)
--httpPort=$HTTP_PORT,用來(lái)設(shè)置jenkins運(yùn)行時(shí)的web端口。
--httpsPort=$HTTP_PORT,表示使用https協(xié)議。
--httpListenAddress=$HTTP_HOST,用來(lái)指定jenkins監(jiān)聽(tīng)的ip范圍,默認(rèn)為所有的ip都可以訪問(wèn)此jenkins server。
?
6 修改jenkins的timezone
如果jenkins所在的server的timezone不同于用戶的timezone,這時(shí)候需要修改jenkins的timezone,需要在jenkins啟動(dòng)的時(shí)候增加下列參數(shù)-Dorg.apache.commons.jelly.tags.fmt.timeZone=TZ
7 最好通過(guò)一個(gè)腳本來(lái)啟動(dòng)jenkins,確保jenkins每次都運(yùn)行在相同的環(huán)境下,例如
startjenkins.bat
set JENKINS_HOME=c:\jenkins
cd /d %JENKINS_HOME%
java -jar %JENKINS_HOME%\jenkins.war --httpPort=8000
8 jenkins在后臺(tái)運(yùn)行
如果jenkins是部署在servlet容器中,例如apache,tomcat中。因?yàn)閟ervlet容器一般都在后臺(tái)運(yùn)行了,所以jenkins也就已經(jīng)在后臺(tái)運(yùn)行了。
對(duì)于windows用戶需要在jenkins的管理頁(yè)面中點(diǎn)擊insall as windows service來(lái)將jenkins部署為service。 但是感覺(jué)比較好的方法還是手動(dòng)將啟動(dòng)jenkins的腳本部署為windows service,從而可以更靈活地設(shè)置更多的參數(shù)。9 jenkins的系統(tǒng)信息
可以在jenkins的管理頁(yè)面下的系統(tǒng)信息中,查看所有的jenkins的信息,例如jenkins的啟動(dòng)配置,所依賴的系統(tǒng)的環(huán)境變量,所安裝的plugins。
?
10 jenkins內(nèi)置的環(huán)境變量
BUILD_NUMBER, 唯一標(biāo)識(shí)一次build,例如23;
BUILD_ID,基本上等同于BUILD_NUMBER,但是是字符串,例如2011-11-15_16-06-21;
JOB_NAME, job的名字,例如JavaHelloWorld;
BUILD_TAG, 作用同BUILD_ID,BUILD_NUMBER,用來(lái)全局地唯一標(biāo)識(shí)一此build,例如jenkins-JavaHelloWorld-23;
EXECUTOR_NUMBER, 例如0;
NODE_NAME,slave的名字,例如MyServer01;
NODE_LABELS,slave的label,標(biāo)識(shí)slave的用處,例如JavaHelloWorld MyServer01;
JAVA_HOME, java的home目錄,例如C:\Program Files (x86)\Java\jdk1.7.0_01;
WORKSPACE,job的當(dāng)前工作目錄,例如c:\jenkins\workspace\JavaHelloWorld;
HUDSON_URL = JENKINS_URL, jenkins的url,例如http://localhost:8000/ ;
BUILD_URL,build的url 例如http://localhost:8000/job/JavaHelloWorld/23/;
JOB_URL, job的url,例如http://localhost:8000/job/JavaHelloWorld/;
SVN_REVISION,svn 的revison, 例如4;
http://www.cnblogs.com/itech/archive/2011/11/04/2236230.html
?
在網(wǎng)上貌似沒(méi)有找到Jenkins的中文的太多的文檔,有的都是關(guān)于Hudson的一些零零散散的,所以自己邊學(xué)習(xí)邊實(shí)踐總結(jié)了以下系列文章,希望有助于大家對(duì)于Jenkins的使用。 本系列文章是基于我3年多的SCM+build release經(jīng)驗(yàn),總結(jié)了最常用的最基本功能,文章基本上來(lái)自于Jenkins官方網(wǎng)站的英文幫助的翻譯和實(shí)際的例子和操作的截圖,讓大家能夠快速直觀地學(xué)習(xí)Jenkins。
?
Jenkins是Continous Integration Server,是Hadson的繼續(xù)。 類(lèi)似的產(chǎn)品: CruiseControl,BuildBot,TeamCity,BuildForge,?ElectricCommander等。
[個(gè)人覺(jué)是Jenkins在開(kāi)源的CIServer中的理想的選擇。]
?
http://jenkins-ci.org http://www.cloudbees.com?
Jenkins的突出特點(diǎn):
開(kāi)源免費(fèi);
跨平臺(tái),支持所有的平臺(tái);
master/slave支持分布式的build;
web形式的可視化的管理頁(yè)面;
安裝配置超級(jí)簡(jiǎn)單;
tips及時(shí)快速的幫助;
已有的200多個(gè)插件;
?
Jenkins的入門(mén)教程:
Jenkins master在windows上安裝 jenkins master在centos上的安裝 Jenkins 構(gòu)建JavaHelloWorld Jenkins的配置 Jenkins的Windows Slave的配置 Jenkins的Linux的Slave的配置 Jenkins Master/Slave架構(gòu) Jenkins最佳實(shí)踐 Jenkins中執(zhí)行batch和Python Jenkins的授權(quán)和訪問(wèn)控制 Jenkins插件之Perforce訪問(wèn) Jenkins插件之trigger Jenkins插件之構(gòu)建與MSBuild Jenkins插件之環(huán)境變量插件EnvInject Jenkins插件之Workspace cleanup + Copy to slave Jenkins插件之VShpere Cloud Jenkins插件之Publish Over SSH/CIFS/FTP Jenkins插件之Deploy Jenkins插件之Dashboard和wall display Jenkins插件之有用 Jenkins FQA?
官方幫助:https://wiki.jenkins-ci.org/display/JENKINS/Home
apache的使用實(shí)例:https://builds.apache.org
使用jenkins來(lái)build jenkins的實(shí)例:https://ci.jenkins-ci.org/?
?
此系列文章的PDF的下載: Jenkins入門(mén)
http://www.cnblogs.com/itech/archive/2011/11/23/2260009.html
?
?
?
報(bào)錯(cuò)1:jenkins中配置的用戶沒(méi)有讀取倉(cāng)庫(kù)的權(quán)限
Cloning repository git@192.168.1.1:project/app-ms.git> /usr/bin/git init /var/lib/jenkins/workspace/app-ms # timeout=10 Fetching upstream changes from git@192.168.1.1:project/app-ms.git> /usr/bin/git --version # timeout=10> /usr/bin/git fetch --tags --progress git@192.168.1.1:project/app-ms.git +refs/heads/*:refs/remotes/origin/* ERROR: Error cloning remote repo 'origin' hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress git@192.168.1.1:project/app-ms.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: GitLab: The project you were looking for could not be found. fatal: Could not read from remote repository.Please make sure you have the correct access rights and the repository exists.at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442)at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:655)at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1152)at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1192)at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:120)at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:90)at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:77)at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)at java.util.concurrent.FutureTask.run(FutureTask.java:266)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)at java.lang.Thread.run(Thread.java:745)?
報(bào)錯(cuò)2:項(xiàng)目目錄層級(jí)與piple中的配置不一致
start compile and package [Pipeline] sh + mvn -f app-ms/pom.xml -U -am -Dmaven.test.skip=true clean package -P FAT --settings /root/.m2/settings.xml POM file app-ms/pom.xml specified with the -f/--file command line argument does not exist [INFO] Scanning for projects... [ERROR] [ERROR] Some problems were encountered while processing the POMs: [FATAL] Non-readable POM /var/lib/jenkins/workspace/app-ms/app-ms/pom.xml: /var/lib/jenkins/workspace/app-ms/app-ms/pom.xml (No such file or directory) @ @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project (/var/lib/jenkins/workspace/app-ms/app-ms/pom.xml) has 1 error [ERROR] Non-readable POM /var/lib/jenkins/workspace/app-ms/app-ms/pom.xml: /var/lib/jenkins/workspace/app-ms/app-ms/pom.xml (No such file or directory) [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (上傳部署) Stage "上傳部署" skipped due to earlier failure(s) [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code 1 Finished: FAILURE
將pipleLine中的 mvn -f pom.xml?這條命令的數(shù)據(jù)更改一下?
?
問(wèn)題3:打包的沒(méi)有在<build>中指定finalName?導(dǎo)致jar的名字不對(duì)
/var/lib/jenkins/pinpoint-ms.sh: line 41: cd: /var/lib/jenkins/workspace/app-ms/app-ms: No such file or directory ingress enabled is false image name is newhub.app.com/app-ms-fat:201904252042_5f1524a release name is app-ms-fat /var/lib/jenkins/pinpoint-ms.sh: line 64: cd: /code/app-ms/app-ms: No such file or directory /var/lib/jenkins/pinpoint-ms.sh: line 65: cd: /code/app-ms/app-ms/app-ms: No such file or directory /var/lib/jenkins/pinpoint-ms.sh: line 66: cd: /code/app-ms/app-ms/app-ms/app-ms: No such file or directory mv: cannot stat ‘target/app-ms.jar’: No such file or directory 11111111 Dockerfile already exsits Sending build context to Docker daemon 50.72 MBStep 1/4 : FROM newhub.app.com/oracle-jdk:8-cst---> c11aa95ae33a48 Step 2/4 : COPY target/app-ms.jar app.jar lstat target/app-ms.jar: no such file or directory [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code 1 Finished: FAILURE?
?
轉(zhuǎn)載于:https://www.cnblogs.com/softidea/p/4523212.html
總結(jié)
以上是生活随笔為你收集整理的Jenkins 部署的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 一个由ul l构成的漂亮的菜单样式i
- 下一篇: RubyMotion 指南:API 驱动