centeros7 安装配置环境jdk1.8的教程(cent os7.4安装)-pg电子平台

大家好!今天让小编来大家介绍下关于centeros7 安装配置环境jdk1.8的教程的问题,以下是酷知号的小编对此问题的归纳整理,让我们一起来看看吧。

服务器

1.先卸载centeros自带jdk

rpm-qa|grepopenjdk

查询出来的自带的openjdk

2.删除

rpm-e--nodeps

3.再次查询

rpm-qa|grepjdk

4.在usr/local创建文件夹

cd/usr/local
mkdirja

5.将jdk1.8放到刚刚创建的文件中

cd/usr/local/ja

用xftp上传后解压

tar-zxvfjdk-8u181-linux-x64.tar.gz

6.进入刚刚解压的文件夹

cdjdk1.8.0_181/pwd#(这一步记录jdk1.8的路径,一会配置环境用)

7.配置环境

vim/etc/profile

按i插入下面路径

exportja_home=/usr/local/ja/jdk1.8.0_181exportclasspath=.:$ja_home/jre/lib/rt.jar:$ja_home/lib/dt.jar:$ja_home/lib/tools.jarexportpath=$path:$ja_home/bin

按esc后:wq退出后

source/etc/profile

8.查看是否成功

ja-version

men 环境配置

1.在/usr/local 下创建men文件夹

cd/usr/localmkdirmen

2.进去新建的文件夹

cdmen

上传 apache-men-3.5.4-bin.zip

3.解压

unzipapache-men-3.5.4-bin.zip

4.进入解压的文件夹

cdapache-men-3.5.4/pwd#(记录下这个路径,一会配置环境用到)

5.配置环境

vim/etc/profile

按i插入下面

exportmen_home=/usr/local/men/apache-men-3.5.4exportpath=$path:$men_home/bin

按esc后:wq保存后

source/etc/profile

6.查看是否成功

mvn-v

centeros7安装git

yuminstallgit

一路下来y即可

查看是否是成功

git--version

查看git命令地址

which-agit

到此环境已经搭建好,开始对men,gitlab搭建。

gitlab搭建

1.新建 /etc/yum.repos.d/gitlab-ce.repo

vim/etc/yum.repos.d/gitlab-ce.repo

后按下 i 键 插入下面内容

[gitlab-ce]name=gitlabcerepositorybaseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/gpgcheck=0enabled=1

2.

sudoyummakecachesudoyuminstallgitlab-ce#(安装最新的)或sudoyuminstallgitlab-ce-12.0.4#(指定版本号)

3.配置 external_url

vim/etc/gitlab/gitlab.rb

修改external_url地址 为:http://本机地址:端口号/

本机地址查看:ifconfig

查看端口号运行的应用 lsof -i:端口号

4.

gitlab-ctlreconfigure

5.

gitlab-ctlrestart#启动gitlab-ctlstart|stop|status|restart#其他操作

6.访问

http://本机地址:端口号/

常见问题gitlab502: 这个是端口被占用

确保端口不被占用后从4开始继续来一遍

centeros7 搭建men私服

下载nexus3.x:

https://www.sonatype.com/download-oss-sonatype

1.在/usr/local下创建nexus文件

cd/usr/localmkdirnexuscdnexus

2.上传刚刚下载的nexus压缩包并解压

tar-zxvfnexus-3.18.1-01-unix.tar.gz

3.

cdnexus-3.18.1-01/bin/ls

4.启动

./nexusrun&

5.开启远程访问端口

firewall-cmd--zone=public--add-port=8081/tcp--permanentfirewall-cmd--reload

浏览器访问

6.设置开机自启动

1.创建服务

vim/usr/lib/systemd/system/nexus.service

2.按i将下面复制进去

[unit]description=nexusservice[service]type=forkinglimitnofile=65536#警告处理execstart=/usr/local/nexus/nexus-3.7.1-02/bin/nexusstartexecreload=/usr/local/nexus/nexus-3.7.1-02/bin/nexusrestartexecstop=/usr/local/nexus/nexus-3.7.1-02/bin/nexusstoprestart=on-failure[install]wantedby=multi-user.target

3.将服务加入开机启动

systemctlenablenexus.service

4.重新加载配置文件

systemctldaemon-reload

7.运行用户为root (编辑nexus bin下的nexus.rc)

cd/usr/local/nexus/nexus-3.18.1-01/bin/vimnexus.rc

内容改为:

run_as_user=root

8.修改nexus3启动时要使用的jdk版本

cd/usr/local/nexus/nexus-3.18.1-01/bin/vimnexus

按i将下面添加进去

install4j_ja_home_override=/usr/local/ja/jdk1.8.0_181

ja_home地址可以用echo $ja_home 输出 (前提是/etc/profile有export)

9.修改nexus3默认端口

文件在nexus-xx

etc/nexus-default.properties

这里已经搭建好了,下面是deploy到私服和从私服上下载下来测试

1.创建facade 上传到私服

在/usr下创建projects

cd/usrmkdirprojects

将改zip解压到projects进入到pom.xml所在目录

mvndeploy-dmen.test.skip=true-u

已经上传成功

这里要把allow anonymous users to access the server(允许匿名用户访问服务器)

因为本地men没有配置用户

也可以用idea men命令depoly



  4.0.0
  com.netease
  men_test_demo
  1.0.0-snapshot
  jar
  
  
    1.8
    utf-8
    3.6.1
    192.168.20.143:8081
  
  
  
    
      nexus-releases
      nexus private release repository
      http://${nexus.host}/repository/men-releases
    
    
      nexus-snapshots
      nexus private snapshot repository
      http://${nexus.host}/repository/men-snapshots
    
  
  
  
    ${project.artifactid}-${project.version}
    
      
        org.apache.men.plugins
        men-compiler-plugin
        ${men-compiler-plugin.version}
        
          ${ja.version}
          ${ja.version}
          ${project.build.sourceencoding}
        
      
    
  

settings.xml中servers中定义的id一致

在settings 添加下面镜像

centralhttp://repo1.men.org/men2central

最后settings文件。到这儿jar包已经可以发布到私服上去了

再看怎么拉取的

men_demo_impl项目的pom.xml



  4.0.0
  com.netease
  men_demo_impl
  1.0-snapshot
  
    org.springframework.boot
    spring-boot-starter-parent
    2.0.5.release
     
  
  
  
    1.8
    utf-8
    3.6.1
    192.168.20.143:8081
    finchley.sr1
  
  
  
    
      nexus-aliyun-repo
      nexus aliyun repo
      http://men.aliyun.com/nexus/content/groups/public
    
    
    
      men-public
      men public
      http://192.168.20.143:8081/repository/men-public/
    
  
  
    
      
        org.springframework.cloud
        spring-cloud-dependencies
        ${spring-cloud.version}
        pom
        import
      
    
  
  
  
    
      org.springframework.cloud
      spring-cloud-starter-netflix-eureka-server
    
    
      com.netease
      men_test_demo
      1.0.0-snapshot
    
  
  
   
    
      org.springframework.boot
      spring-boot-men-plugin
    
   
  

配置完成后就会自动去私服下载jar了

jenkins搭建

1.查看环境版本

ja-version#没有的话查看上文jdk1.8安装mvn-v#没有的话查看上文men安装git--version#没有的话查看上文git安装

2.安装jenkenis

添加jenkins源:

sudowget-o/etc/yum.repos.d/jenkins.repohttp://jenkins-ci.org/redhat/jenkins.reposudorpm--importhttp://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key

3.安装

yuminstalljenkins

4.启动

sudoservicejenkinsstart

5.访问

http://ip:8080/#jenkenis默认是8080

第一次密码:

vim /var/lib/jenkins/secrets/initialadminpassword

点安装推荐的插件(后面的选择安装不知道安装什么)

修改jenkins端口

vim/etc/sysconfig/jenkins

将jenkins_port=8080 ===> 修改成未占用想修改的端口 jenkins_port=8089

重启服务

servicejenkinsrestart

遇到的问题:重装了jdk, ja地址变了

启动jenkins报错: job for jenkins.service failed because the control process exited with error code. see systemctl status jenkins.service and journalctl -xe for details.

按提示输入systemctl status jenkins.service

解决方法:

1> 查看当前ja的环境变量

echo$ja_home

2> 复制ja的环境变量地址, 编辑/etc/init.d/jenkins文件, 指定位置添加该地址, 后缀附上/bin/ja

vim/etc/init.d/jenkins

重点是配置jenkins:

1.配置全局jdk men git

点manage jenkins(系统管理) –> global tool configuaration(全局工具配置)

1.men配置:配置settings.xml地址

2.配置jdk地址 (可以用echo $ja_home获取)

3.git配置地址 可以用(which -a git查看)

4.men配置地址

2.新建任务

3.配置任务

1.配置源码管理 下面version是gitlab的版本号

repository url:访问的仓库名称 credentials:访问账目密码或者ssh证书 branch specifier (blank for ‘any\’):访问的分支,可以多个源码库浏览器:选择源码库服务器 url:源码仓库url version:源码库服务器版本号

2.配置构建

cleancompilepackageinstalldeploy-dmen.test.skip=true-u#将jar发布

然后应用,配置完成!

3.在my view(我的视图) -> 找到新建的项目 –> 点击build now(立即构建)

在构建历史中点击刚刚的构建如下图: #1 : 是构建的id ,控制台输出: 可以看到具体的输出

下面是输入日志 可以看到以前拉取到指定的项目master分支

started by user root
running as system
building in workspace /var/lib/jenkins/workspace/first
using credential fad2813a-c894-4386-ae16-11d6e6d349d4
cloning the remote git repository
cloning repository http://192.168.20.137:9029/root/wx-s.git
> /usr/local/git/bin/git init /var/lib/jenkins/workspace/first # timeout=10
fetching upstream changes from http://192.168.20.137:9029/root/wx-s.git
> /usr/local/git/bin/git --version # timeout=10
using git_askpass to set credentials
> /usr/local/git/bin/git fetch --tags --progress http://192.168.20.137:9029/root/wx-s.git  refs/heads/*:refs/remotes/origin/*
> /usr/local/git/bin/git config remote.origin.url http://192.168.20.137:9029/root/wx-s.git # timeout=10
> /usr/local/git/bin/git config --add remote.origin.fetch  refs/heads/*:refs/remotes/origin/* # timeout=10
> /usr/local/git/bin/git config remote.origin.url http://192.168.20.137:9029/root/wx-s.git # timeout=10
fetching upstream changes from http://192.168.20.137:9029/root/wx-s.git
using git_askpass to set credentials
> /usr/local/git/bin/git fetch --tags --progress http://192.168.20.137:9029/root/wx-s.git  refs/heads/*:refs/remotes/origin/*
> /usr/local/git/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> /usr/local/git/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
checking out revision 47d13c3ca0bc12fc0465c3e4c582b2c542276eb6 (refs/remotes/origin/master)
> /usr/local/git/bin/git config core.sparsecheckout # timeout=10
> /usr/local/git/bin/git checkout -f 47d13c3ca0bc12fc0465c3e4c582b2c542276eb6
commit message: 更新 pom.xml
first time build. skipping changelog.
[first] $ /project/ja/men/apache-men-3.6.1/bin/mvn -s /project/ja/men/apache-men-3.6.1/conf/settings.xml -gs /project/ja/men/apache-men-3.6.1/conf/settings.xml clean package
[info] scanning for projects...
[warning]
[warning] some problems were encountered while building the effective model for com.guojin:gjmetal-wx-s:jar:1.0.0.1-snapshot
[warning] \'dependencies.dependency.(groupid:artifactid:type:classifier)\' must be unique: org.apache.httpcomponents:httpclient:jar -> version (?) vs 4.5.6 @ line 155, column 21
[warning]
[warning] it is highly recommended to fix these problems because they threaten the stability of your build.
[warning]
[warning] for this reason, future men versions might no longer support building such malformed projects.
[warning]
[info]
[info] ---------------------< com.guojin:gjmetal-wx-s >----------------------
[info] building gjmetal-wx-s 1.0.0.1-snapshot
[info] --------------------------------[ jar ]---------------------------------
[info]
[info] --- men-clean-plugin:2.5:clean (default-clean) @ gjmetal-wx-s ---
[info]
[info] --- jacoco-men-plugin:0.7.9:prepare-agent (pre-test) @ gjmetal-wx-s ---
[info] argline set to -jaagent:/var/lib/jenkins/.m2/repository/org/jacoco/org.jacoco.agent/0.7.9/org.jacoco.agent-0.7.9-runtime.jar=destfile=/var/lib/jenkins/workspace/first/target/jacoco.exec,includes=com.gjmetal.*
[info]
[info] --- men-resources-plugin:2.6:resources (default-resources) @ gjmetal-wx-s ---
[info] using \'utf-8\' encoding to copy filtered resources.
[info] copying 1 resource
[info]
[info] --- men-compiler-plugin:3.6.1:compile (default-compile) @ gjmetal-wx-s ---
[info] changes detected - recompiling the module!
[info] compiling 27 source files to /var/lib/jenkins/workspace/first/target/classes
[info] -------------------------------------------------------------
[error] compilation error :
[info] -------------------------------------------------------------
[error] /var/lib/jenkins/workspace/first/src/main/ja/com/gjmetal/swagger2.ja:[4,40] 程序包org.fuelteam.springboot.swagger2不存在
[error] /var/lib/jenkins/workspace/first/src/main/ja/com/gjmetal/swagger2.ja:[21,2] 找不到符号
 符号: 类 enableswagger2
[info] 2 errors
[info] -------------------------------------------------------------
[info] ------------------------------------------------------------------------
[info] build failure
[info] ------------------------------------------------------------------------
[info] total time: 9.183 s
[info] finished at: 2019-08-23t17:05:09 08:00
[info] ------------------------------------------------------------------------
[error] failed to execute goal org.apache.men.plugins:men-compiler-plugin:3.6.1:compile (default-compile) on project gjmetal-wx-s: compilation failure: compilation failure:
[error] /var/lib/jenkins/workspace/first/src/main/ja/com/gjmetal/swagger2.ja:[4,40] 程序包org.fuelteam.springboot.swagger2不存在
[error] /var/lib/jenkins/workspace/first/src/main/ja/com/gjmetal/swagger2.ja:[21,2] 找不到符号
[error]  符号: 类 enableswagger2
[error] -> [help 1]
[error]
[error] to see the full stack trace of the errors, re-run men with the -e switch.
[error] re-run men 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/men/mojofailureexception
build step \'invoke top-level men targets\' marked build as failure
finished: failure

上面报错是项目问题,可以看到已经拉取到项目了。所以要保证项目的正确性。

下面是正确的两个项目运行实例在搭建好gitlab nexus jenkins后实现自动发jar到私服及启动jar项目

背景: gitlab nexus jenkins都已经完成了

1.从gitlab下载项目后发布jar到私服

重新配置gitlab地址:

配置men命令:

cleancompilepackageinstalldeploy-dmen.test.skip=true-u

点击build now 然后看控制台输出如下

started by user root
running as system
building in workspace /var/lib/jenkins/workspace/men_home
using credential fad2813a-c894-4386-ae16-11d6e6d349d4
> /usr/local/git/bin/git rev-parse --is-inside-work-tree # timeout=10
fetching changes from the remote git repository
> /usr/local/git/bin/git config remote.origin.url http://192.168.20.143:8083/root/men_demo.git # timeout=10
fetching upstream changes from http://192.168.20.143:8083/root/men_demo.git
> /usr/local/git/bin/git --version # timeout=10
using git_askpass to set credentials
> /usr/local/git/bin/git fetch --tags --progress http://192.168.20.143:8083/root/men_demo.git  refs/heads/*:refs/remotes/origin/*
> /usr/local/git/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> /usr/local/git/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
checking out revision a26adc740d331eabe5b0fb2a46b372dbf6673d2c (refs/remotes/origin/master)
> /usr/local/git/bin/git config core.sparsecheckout # timeout=10
> /usr/local/git/bin/git checkout -f a26adc740d331eabe5b0fb2a46b372dbf6673d2c
commit message: update pom.xml
> /usr/local/git/bin/git rev-list --no-walk a26adc740d331eabe5b0fb2a46b372dbf6673d2c # timeout=10
[men_home] $ /project/ja/men/apache-men-3.6.1/bin/mvn -s /project/ja/men/apache-men-3.6.1/conf/settings.xml -gs /project/ja/men/apache-men-3.6.1/conf/settings.xml clean compile package install deploy -dmen.test.skip=true -u
[info] scanning for projects...
[info]
[info] --------------------< com.netease:men_test_demo >---------------------
[info] building men_test_demo 1.0.0-snapshot
[info] --------------------------------[ jar ]---------------------------------
[info]
[info] --- men-clean-plugin:2.5:clean (default-clean) @ men_test_demo ---
[info] deleting /var/lib/jenkins/workspace/men_home/target
[info]
[info] --- men-resources-plugin:2.6:resources (default-resources) @ men_test_demo ---
[info] using \'utf-8\' encoding to copy filtered resources.
[info] skip non existing resourcedirectory /var/lib/jenkins/workspace/men_home/src/main/resources
[info]
[info] --- men-compiler-plugin:3.6.1:compile (default-compile) @ men_test_demo ---
[info] changes detected - recompiling the module!
[info] compiling 1 source file to /var/lib/jenkins/workspace/men_home/target/classes
[info]
[info] --- men-resources-plugin:2.6:resources (default-resources) @ men_test_demo ---
[info] using \'utf-8\' encoding to copy filtered resources.
[info] skip non existing resourcedirectory /var/lib/jenkins/workspace/men_home/src/main/resources
[info]
[info] --- men-compiler-plugin:3.6.1:compile (default-compile) @ men_test_demo ---
[info] nothing to compile - all classes are up to date
[info]
[info] --- men-resources-plugin:2.6:testresources (default-testresources) @ men_test_demo ---
[info] not copying test resources
[info]
[info] --- men-compiler-plugin:3.6.1:testcompile (default-testcompile) @ men_test_demo ---
[info] not compiling test sources
[info]
[info] --- men-surefire-plugin:2.12.4:test (default-test) @ men_test_demo ---
[info] tests are skipped.
[info]
[info] --- men-jar-plugin:2.4:jar (default-jar) @ men_test_demo ---
[info] building jar: /var/lib/jenkins/workspace/men_home/target/men_test_demo-1.0.0-snapshot.jar
[info]
[info] --- men-resources-plugin:2.6:resources (default-resources) @ men_test_demo ---
[info] using \'utf-8\' encoding to copy filtered resources.
[info] skip non existing resourcedirectory /var/lib/jenkins/workspace/men_home/src/main/resources
[info]
[info] --- men-compiler-plugin:3.6.1:compile (default-compile) @ men_test_demo ---
[info] nothing to compile - all classes are up to date
[info]
[info] --- men-resources-plugin:2.6:testresources (default-testresources) @ men_test_demo ---
[info] not copying test resources
[info]
[info] --- men-compiler-plugin:3.6.1:testcompile (default-testcompile) @ men_test_demo ---
[info] not compiling test sources
[info]
[info] --- men-surefire-plugin:2.12.4:test (default-test) @ men_test_demo ---
[info] tests are skipped.
[info]
[info] --- men-jar-plugin:2.4:jar (default-jar) @ men_test_demo ---
[info]
[info] --- men-install-plugin:2.4:install (default-install) @ men_test_demo ---
[info] installing /var/lib/jenkins/workspace/men_home/target/men_test_demo-1.0.0-snapshot.jar to /var/lib/jenkins/.m2/repository/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-snapshot.jar
[info] installing /var/lib/jenkins/workspace/men_home/pom.xml to /var/lib/jenkins/.m2/repository/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-snapshot.pom
[info]
[info] --- men-resources-plugin:2.6:resources (default-resources) @ men_test_demo ---
[info] using \'utf-8\' encoding to copy filtered resources.
[info] skip non existing resourcedirectory /var/lib/jenkins/workspace/men_home/src/main/resources
[info]
[info] --- men-compiler-plugin:3.6.1:compile (default-compile) @ men_test_demo ---
[info] nothing to compile - all classes are up to date
[info]
[info] --- men-resources-plugin:2.6:testresources (default-testresources) @ men_test_demo ---
[info] not copying test resources
[info]
[info] --- men-compiler-plugin:3.6.1:testcompile (default-testcompile) @ men_test_demo ---
[info] not compiling test sources
[info]
[info] --- men-surefire-plugin:2.12.4:test (default-test) @ men_test_demo ---
[info] tests are skipped.
[info]
[info] --- men-jar-plugin:2.4:jar (default-jar) @ men_test_demo ---
[info]
[info] --- men-install-plugin:2.4:install (default-install) @ men_test_demo ---
[info] installing /var/lib/jenkins/workspace/men_home/target/men_test_demo-1.0.0-snapshot.jar to /var/lib/jenkins/.m2/repository/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-snapshot.jar
[info] installing /var/lib/jenkins/workspace/men_home/pom.xml to /var/lib/jenkins/.m2/repository/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-snapshot.pom
[info]
[info] --- men-deploy-plugin:2.7:deploy (default-deploy) @ men_test_demo ---
downloading from nexus-snapshots: http://192.168.20.143:8081/repository/men-snapshots/com/netease/men_test_demo/1.0.0-snapshot/men-metadata.xml
progress (1): 776 b
downloaded from nexus-snapshots: http://192.168.20.143:8081/repository/men-snapshots/com/netease/men_test_demo/1.0.0-snapshot/men-metadata.xml (776 b at 6.5 kb/s)
uploading to nexus-snapshots: http://192.168.20.143:8081/repository/men-snapshots/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-20190827.062446-3.jar
progress (1): 2.6 kb
uploaded to nexus-snapshots: http://192.168.20.143:8081/repository/men-snapshots/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-20190827.062446-3.jar (2.6 kb at 13 kb/s)
uploading to nexus-snapshots: http://192.168.20.143:8081/repository/men-snapshots/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-20190827.062446-3.pom
progress (1): 2.1 kb
uploaded to nexus-snapshots: http://192.168.20.143:8081/repository/men-snapshots/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-20190827.062446-3.pom (2.1 kb at 19 kb/s)
downloading from nexus-snapshots: http://192.168.20.143:8081/repository/men-snapshots/com/netease/men_test_demo/men-metadata.xml
progress (1): 286 b
downloaded from nexus-snapshots: http://192.168.20.143:8081/repository/men-snapshots/com/netease/men_test_demo/men-metadata.xml (286 b at 11 kb/s)
uploading to nexus-snapshots: http://192.168.20.143:8081/repository/men-snapshots/com/netease/men_test_demo/1.0.0-snapshot/men-metadata.xml
progress (1): 776 b
uploaded to nexus-snapshots: http://192.168.20.143:8081/repository/men-snapshots/com/netease/men_test_demo/1.0.0-snapshot/men-metadata.xml (776 b at 4.6 kb/s)
uploading to nexus-snapshots: http://192.168.20.143:8081/repository/men-snapshots/com/netease/men_test_demo/men-metadata.xml
progress (1): 286 b
uploaded to nexus-snapshots: http://192.168.20.143:8081/repository/men-snapshots/com/netease/men_test_demo/men-metadata.xml (286 b at 2.5 kb/s)
[info] ------------------------------------------------------------------------
[info] build success
[info] ------------------------------------------------------------------------
[info] total time: 3.640 s
[info] finished at: 2019-08-27t14:24:47 08:00
[info] ------------------------------------------------------------------------
finished: success

2.将运行的jar发布到指定的机器

确保jenkins安装了publish over ssh插件 manage jenkins -> manage plugins -> 搜索ssh

然后配置ssh

配置后点击test configuration 出现success

配置完成后新建item(项目)只是多加了一个构建后(注意前面的配置要想要的改 :项目的git地址)

#最后一个执行的脚本放到的位置是/projects/scripts
mkdir scripts
vim run.sh
#按i将下面内容复制进去
project_name=$1
port_no=$2
#echo $project_name
#echo $port_no
. /etc/profile
# 进入到项目
cd /projects/$project_name
# 找到原进程,kill
pid=$(ps -ef | grep ja| grep $project_name|awk -f \'[ ] \' \'{print $2}\')
kill -9 $pid
#启动jar
nohup ja -jar $project_name-1.0-snapshot.jar --server.port=$port_no -server -xmx1000m -xms1000m -xmn700m -xx: useparallelgc &
echo starting service...
sleep 20
#根据重启后是否有当前应用判断启动是否成功
pid=$(ps -ef | grep ja| grep $project_name|awk -f \'[ ] \' \'{print $2}\')
#echo $pid
if [ -z $pid ];then
 echo 启动失败
 exit 1
else
 echo $project_name : $pid success
fi

现在立即构建 查看控制台输出

started by user root
running as system
building in workspace /var/lib/jenkins/workspace/men_demo_impl
using credential fad2813a-c894-4386-ae16-11d6e6d349d4
> /usr/local/git/bin/git rev-parse --is-inside-work-tree # timeout=10
fetching changes from the remote git repository
> /usr/local/git/bin/git config remote.origin.url http://192.168.20.143:8083/root/men_demo_impl.git # timeout=10
fetching upstream changes from http://192.168.20.143:8083/root/men_demo_impl.git
> /usr/local/git/bin/git --version # timeout=10
using git_askpass to set credentials
> /usr/local/git/bin/git fetch --tags --progress http://192.168.20.143:8083/root/men_demo_impl.git  refs/heads/*:refs/remotes/origin/*
seen branch in repository origin/master
seen 1 remote branch
> /usr/local/git/bin/git show-ref --tags -d # timeout=10
checking out revision bf0f9bd981c053359167a0e46e517f4f936c8c98 (origin/master)
> /usr/local/git/bin/git config core.sparsecheckout # timeout=10
> /usr/local/git/bin/git checkout -f bf0f9bd981c053359167a0e46e517f4f936c8c98
commit message: update testdemoimpl.ja
> /usr/local/git/bin/git rev-list --no-walk bf0f9bd981c053359167a0e46e517f4f936c8c98 # timeout=10
[men_demo_impl] $ /project/ja/men/apache-men-3.6.1/bin/mvn -s /project/ja/men/apache-men-3.6.1/conf/settings.xml -gs /project/ja/men/apache-men-3.6.1/conf/settings.xml clean compile package -dmen.test.skip=true -u
[info] scanning for projects...
[info]
[info] --------------------< com.netease:men_demo_impl >---------------------
[info] building men_demo_impl 1.0-snapshot
[info] --------------------------------[ jar ]---------------------------------
downloading from nexus-aliyun-repo: http://men.aliyun.com/nexus/content/groups/public/com/netease/men_test_demo/1.0.0-snapshot/men-metadata.xml
downloading from men-public: http://192.168.20.143:8081/repository/men-public/com/netease/men_test_demo/1.0.0-snapshot/men-metadata.xml
progress (1): 776 b
downloaded from men-public: http://192.168.20.143:8081/repository/men-public/com/netease/men_test_demo/1.0.0-snapshot/men-metadata.xml (776 b at 4.2 kb/s)
downloading from nexus-aliyun-repo: http://men.aliyun.com/nexus/content/groups/public/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-20190827.062446-3.pom
downloading from men-public: http://192.168.20.143:8081/repository/men-public/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-20190827.062446-3.pom
progress (1): 2.1 kb
downloaded from men-public: http://192.168.20.143:8081/repository/men-public/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-20190827.062446-3.pom (2.1 kb at 47 kb/s)
downloading from men-public: http://192.168.20.143:8081/repository/men-public/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-20190827.062446-3.jar
progress (1): 2.6 kb
downloaded from men-public: http://192.168.20.143:8081/repository/men-public/com/netease/men_test_demo/1.0.0-snapshot/men_test_demo-1.0.0-20190827.062446-3.jar (2.6 kb at 67 kb/s)
[info]
[info] --- men-clean-plugin:3.0.0:clean (default-clean) @ men_demo_impl ---
[info] deleting /var/lib/jenkins/workspace/men_demo_impl/target
[info]
[info] --- men-resources-plugin:3.0.2:resources (default-resources) @ men_demo_impl ---
[info] using \'utf-8\' encoding to copy filtered resources.
[info] copying 1 resource
[info] copying 0 resource
[info]
[info] --- men-compiler-plugin:3.6.1:compile (default-compile) @ men_demo_impl ---
[info] changes detected - recompiling the module!
[info] compiling 2 source files to /var/lib/jenkins/workspace/men_demo_impl/target/classes
[info]
[info] --- men-resources-plugin:3.0.2:resources (default-resources) @ men_demo_impl ---
[info] using \'utf-8\' encoding to copy filtered resources.
[info] copying 1 resource
[info] copying 0 resource
[info]
[info] --- men-compiler-plugin:3.6.1:compile (default-compile) @ men_demo_impl ---
[info] nothing to compile - all classes are up to date
[info]
[info] --- men-resources-plugin:3.0.2:testresources (default-testresources) @ men_demo_impl ---
[info] not copying test resources
[info]
[info] --- men-compiler-plugin:3.6.1:testcompile (default-testcompile) @ men_demo_impl ---
[info] not compiling test sources
[info]
[info] --- men-surefire-plugin:2.21.0:test (default-test) @ men_demo_impl ---
[info] tests are skipped.
[info]
[info] --- men-jar-plugin:3.0.2:jar (default-jar) @ men_demo_impl ---
[info] building jar: /var/lib/jenkins/workspace/men_demo_impl/target/men_demo_impl-1.0-snapshot.jar
[info]
[info] --- spring-boot-men-plugin:2.0.5.release:repackage (default) @ men_demo_impl ---
[info] ------------------------------------------------------------------------
[info] build success
[info] ------------------------------------------------------------------------
[info] total time: 11.163 s
[info] finished at: 2019-08-27t15:00:40 08:00
[info] ------------------------------------------------------------------------
ssh: connecting from host [localhost.localdomain]
ssh: connecting with configuration [192.168.20.143] ...
ssh: exec: stdout/stderr from command [sh /projects/scripts/run.sh men_demo_impl 10010] ...
starting service...
nohup: 把输出追加到nohup.out
men_demo_impl : 4406 success
ssh: exec: completed after 20,262 ms
ssh: disconnecting configuration [192.168.20.143] ...
ssh: transferred 1 file(s)
finished: success

可以看到ssh已经有jar 并运行了。

以上就是小编对于centeros7 安装配置环境jdk1.8的教程问题和相关问题的解答了,centeros7 安装配置环境jdk1.8的教程的问题希望对你有用!

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文链接:https://www.andon8.com/398367.html

网站地图