天天看點

jenkins 伺服器的安裝

                jenkins 伺服器的安裝 

安裝環境 centos7 系列 

安裝方式 yum 安裝 

安裝jenkins 需要首先配置 jdk 

配置yum 源 

導入公鑰 

安裝 

yum install jenkins -y 

檢視安裝後生成的檔案 

/usr/lib/jenkins/jenkins.war ## jenkins安裝目錄,WAR包會放在這裡 

/etc/sysconfig/jenkins  ## 配置檔案

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

<code>## Path:        Development/Jenkins</code>

<code>## Description: Jenkins Continuous Integration Server</code>

<code>## Type:        string</code>

<code>## Default:     "/var/lib/jenkins"</code>

<code>## ServiceRestart: jenkins</code>

<code>#</code>

<code># Directory where Jenkins store its configuration and working</code>

<code># files (checkouts, build reports, artifacts, ...).</code>

<code>JENKINS_HOME=</code><code>"/var/lib/jenkins"</code>     <code>###jenkins安裝目錄,WAR包會放在這裡 </code>

<code>## Default:     ""</code>

<code># Java executable to run Jenkins</code>

<code># When left empty, we'll try to find the suitable Java.</code>

<code>JENKINS_JAVA_CMD=</code><code>""</code>

<code>## Default:     "jenkins"</code>

<code># Unix user account that runs the Jenkins daemon</code>

<code># Be careful when you change this, as you need to update</code>

<code># permissions of $JENKINS_HOME and /var/log/jenkins.</code>

<code>JENKINS_USER=</code><code>"jenkins"</code>

<code>## Default: "false"</code>

<code># Whether to skip potentially long-running chown at the</code>

<code># $JENKINS_HOME location. Do not enable this, "true", unless</code>

<code># you know what you're doing. See JENKINS-23273.</code>

<code>#JENKINS_INSTALL_SKIP_CHOWN="false"</code>

<code>## Type: string</code>

<code>## Default:     "-Djava.awt.headless=true"</code>

<code># Options to pass to java when running Jenkins.</code>

<code>JENKINS_JAVA_OPTIONS=</code><code>"-Djava.awt.headless=true"</code>

<code>## Type:        integer(0:65535)</code>

<code>## Default:     8080</code>

<code># Port Jenkins is listening on.</code>

<code># Set to -1 to disable</code>

<code>JENKINS_PORT=</code><code>"8080"</code>

<code># IP address Jenkins listens on for HTTP requests.</code>

<code># Default is all interfaces (0.0.0.0).</code>

<code>JENKINS_LISTEN_ADDRESS=</code><code>""</code>

<code># HTTPS port Jenkins is listening on.</code>

<code># Default is disabled.</code>

<code>JENKINS_HTTPS_PORT=</code><code>""</code>

<code># Path to the keystore in JKS format (as created by the JDK 'keytool').</code>

<code>JENKINS_HTTPS_KEYSTORE=</code><code>""</code>

<code># Password to access the keystore defined in JENKINS_HTTPS_KEYSTORE.</code>

<code>JENKINS_HTTPS_KEYSTORE_PASSWORD=</code><code>""</code>

<code># IP address Jenkins listens on for HTTPS requests.</code>

<code>JENKINS_HTTPS_LISTEN_ADDRESS=</code><code>""</code>

<code>## Type:        integer(1:9)</code>

<code>## Default:     5</code>

<code># Debug level for logs -- the higher the value, the more verbose.</code>

<code># 5 is INFO.</code>

<code>JENKINS_DEBUG_LEVEL=</code><code>"5"</code>

<code>## Type:        yesno</code>

<code>## Default:     no</code>

<code># Whether to enable access logging or not.</code>

<code>JENKINS_ENABLE_ACCESS_LOG=</code><code>"no"</code>

<code>## Type:        integer</code>

<code>## Default:     100</code>

<code># Maximum number of HTTP worker threads.</code>

<code>JENKINS_HANDLER_MAX=</code><code>"100"</code>

<code>## Default:     20</code>

<code># Maximum number of idle HTTP worker threads.</code>

<code>JENKINS_HANDLER_IDLE=</code><code>"20"</code>

<code># Pass arbitrary arguments to Jenkins.</code>

<code># Full option list: java -jar jenkins.war --help</code>

<code>JENKINS_ARGS=</code><code>""</code>

/var/lib/jenkins/   ## 預設的JENKINS_HOME 

<code>-rw-r--r--  1 jenkins jenkins  1592 Feb 27 09:14 config.xml</code>

<code>-rw-r--r--  1 jenkins jenkins   159 Feb 27 09:14 hudson.model.UpdateCenter.xml</code>

<code>-rw-r--r--  1 jenkins jenkins   370 Feb 27 09:19 hudson.plugins.git.GitTool.xml</code>

<code>-rw-------  1 jenkins jenkins  1712 Feb 27 09:14 identity.key.enc</code>

<code>-rw-r--r--  1 jenkins jenkins     4 Feb 27 09:24 jenkins.</code><code>install</code><code>.InstallUtil.lastExecVersion</code>

<code>-rw-r--r--  1 jenkins jenkins     4 Feb 27 09:24 jenkins.</code><code>install</code><code>.UpgradeWizard.state</code>

<code>drwxr-xr-x  2 jenkins jenkins  4096 Feb 27 09:14 jobs</code>

<code>drwxr-xr-x  3 jenkins jenkins  4096 Feb 27 09:14 logs</code>

<code>-rw-r--r--  1 jenkins jenkins   907 Feb 27 09:14 nodeMonitors.xml</code>

<code>drwxr-xr-x  2 jenkins jenkins  4096 Feb 27 09:14 nodes</code>

<code>drwxr-xr-x 72 jenkins jenkins 12288 Feb 27 09:20 plugins</code>

<code>-rw-r--r--  1 jenkins jenkins    64 Feb 27 09:14 secret.key</code>

<code>-rw-r--r--  1 jenkins jenkins     0 Feb 27 09:14 secret.key.not-so-secret</code>

<code>drwx------  4 jenkins jenkins  4096 Feb 27 09:24 secrets</code>

<code>drwxr-xr-x  2 jenkins jenkins  4096 Feb 27 09:19 updates</code>

<code>drwxr-xr-x  2 jenkins jenkins  4096 Feb 27 09:14 userContent</code>

<code>drwxr-xr-x  3 jenkins jenkins  4096 Feb 27 09:24 </code><code>users</code>

<code>drwxr-xr-x  2 jenkins jenkins  4096 Feb 27 09:19 workflow-libs</code>

/etc/rc.d/init.d/jenkins    ##啟東腳本 

/var/log/jenkins/jenkins.log:Jenkins  ##日志檔案

啟動jenkins 服務

systemctl start jenkins 

systemctl start jenkins

Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.

啟動失敗 檢視 報錯資訊 

 Starting LSB: Jenkins Continuous Integration Server...

Starting Jenkins bash: /usr/bin/java: No such file or directory

Feb 27 09:03:12 test-bcliunx-3 jenkins: [FAILED]

沒有找到 java 指令

檢視java 指令 

/opt/jdk1.7.0_51/bin/java

解決方法修改 jenkins 啟動腳本 

vim /etc/rc.d/init.d/jenkins

添加下面的檔案

<a href="https://s3.51cto.com/wyfs02/M00/8E/01/wKioL1izh6jCi0Y_AAAu4GnLFuE275.jpg-wh_500x0-wm_3-wmp_4-s_2447041802.jpg" target="_blank"></a>

啟動jenkis 

web 登入測試 

<a href="http://ip:8080/" target="_blank">http://ip:8080/</a>

根據提示輸入密碼 

安裝所需要的插件 

登入成功後設定管理者密碼 

登入成功後界面如下所示

<a href="https://s5.51cto.com/wyfs02/M01/8E/03/wKiom1izixSCZaCPAABREXJTodw814.jpg-wh_500x0-wm_3-wmp_4-s_2348956895.jpg" target="_blank"></a>

本文轉自 水滴石川1 51CTO部落格,原文連結:http://blog.51cto.com/sdsca/1901554,如需轉載請自行聯系原作者