zoukankan      html  css  js  c++  java
  • Jenkins执行shell脚本时要设置权限

    目前出现了一个问题,当我独自用shell脚本执行启动springBoot时  就可以注册到eureka上

    如果用jenkins执行shell脚本时 就会出现注册不上去的情况

    2020-11-18 13:47:54.808  INFO 29482 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_XIANNANSHAN-USER/172.17.165.145:xiannanshan-user:8060: registering service...
    2020-11-18 13:47:54.994  INFO 29482 --- [extShutdownHook] com.netflix.discovery.DiscoveryClient    : Shutting down DiscoveryClient ...
    2020-11-18 13:47:55.050  INFO 29482 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_XIANNANSHAN-USER/172.17.165.145:xiannanshan-user:8060 - registration status: 204
    2020-11-18 13:47:55.053  INFO 29482 --- [extShutdownHook] com.netflix.discovery.DiscoveryClient    : Unregistering ...
    2020-11-18 13:47:55.246  INFO 29482 --- [extShutdownHook] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_XIANNANSHAN-USER/172.17.165.145:xiannanshan-user:8060 - deregister  status: 200
    2020-11-18 13:47:55.273  INFO 29482 --- [extShutdownHook] com.netflix.discovery.DiscoveryClient    : Completed shut down of DiscoveryClient

    聪明的我领悟到有可能是因为shell脚本没有权限执行文件  

    在Jenkins执行shell脚本时:

    于是在shell脚本前面加上sudo 提权执行

    echo "开始执行maven打包"
    mvn clean install package -Dmaven.test.skip=true
    echo "maven打包完成"
    echo "开始复制jar包"
    pwd
    cd /root/.jenkins/workspace/xiannanshan-parents/
    sh xiannanshan-publish.sh backup user prod
    sodo sh xiannanshan-publish.sh backup cloud-parent prod
    find /root/.jenkins/workspace/xiannanshan-parents -name '*.jar' -exec cp {} /usr/local/xiannanshan/xiannanshan-parents/lib/ ;
    sodo sh xiannanshan-publish.sh restart cloud-parent prod
    sudo sh xiannanshan-publish.sh restart user prod
    

      

  • 相关阅读:
    利用Dom4j创建xml文档
    eclipse安装、使用hibernate插件方法
    “万能数据库查询分析器”用户已基本涵盖当前所有DBMS
    在Dom4j中使用Xpath搜索xml的元素节点
    多线程的一些小问题集锦
    Dalvik虚拟机的运行过程分析
    创建线程的两种方式
    通过xpath查找指定的节点
    Oracle TNS 配置
    c++五种内存分配、堆与栈区别
  • 原文地址:https://www.cnblogs.com/pangyangqi/p/13999403.html
Copyright © 2011-2022 走看看