Jenkins、Shell命令

  • Shell 获取函数的返回值
  • shell函数
  • Jenkins权限控制-Role Strategy Plugin插件使用

jenkins打包报错,原因是git parameter插件需要更新,更新就好了

If you selected revisions as a type of presented data and working space is empty, the plug needs clone the repository, before it can display the contents. This may take some time if you have a slow connection or repository is large.

关闭jenkins
launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
开启jenkins
sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist



  
    StandardOutPath
    /var/log/jenkins/jenkins.log
    StandardErrorPath
    /var/log/jenkins/jenkins.log
    EnvironmentVariables
    
      JENKINS_HOME
      /Users/Shared/Jenkins/Home
    
    GroupName
    daemon
    KeepAlive
    
    Label
    org.jenkins-ci
    ProgramArguments
    
      /bin/bash
      /Library/Application Support/Jenkins/jenkins-runner.sh
    
    RunAtLoad
    
    UserName
    jenkins
    SessionCreate
    
  

一、创建方法传入参数及获取返回参数
1、创建一个属性文件config.properties,用于读取测试,内如如下

name="小明"
age=100
aa.bb.cc=hello world
name='小小鸟'
name=鲲鹏展翅

编写一个读取属性文件的方法并测试

#!/bin/bash
#获取返回值的第一种方式
p_var=""
function prop1(){
   #取最后一条
    p_var=`grep "^$1=" $2 | cut -d'=' -f2 | tail -n 1 | sed 's/\r//'`
    return 0
}
prop1 "name" "./config.properties"
res1=$p_var
echo "=====prop1========"
echo $res1
prop1 "age" "./config.properties"
res2=$p_var
echo $res2
prop1 "aa.bb.cc" "./config.properties"
res3=$p_var
echo $res3

#获取返回值的第二种方式
function prop2(){
  #取第一条
   #grep pattern fileName | cut -d'=' -f2 | sed 's/\r//'
    grep "^$1=" $2 | cut -d'=' -f2 | head -n 1 | sed 's/\r//'
    return 0
}
echo "======prop2========"
result1=`prop2 "name" "./config.properties"`
echo $result1
result2=`prop2 "age" "./config.properties"`
echo $result2
result3=`prop2 "aa.bb.cc" "./config.properties"`
echo $result3

=====prop1========

鲲鹏展翅
100
hello wold
======prop2========
"小明"
100
hello wold

你可能感兴趣的:(Jenkins、Shell命令)