美文网首页
Jenkins、Shell命令

Jenkins、Shell命令

作者: 独孤流 | 来源:发表于2019-07-12 16:30 被阅读0次

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

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>StandardOutPath</key>
    <string>/var/log/jenkins/jenkins.log</string>
    <key>StandardErrorPath</key>
    <string>/var/log/jenkins/jenkins.log</string>
    <key>EnvironmentVariables</key>
    <dict>
      <key>JENKINS_HOME</key>
      <string>/Users/Shared/Jenkins/Home</string>
    </dict>
    <key>GroupName</key>
    <string>daemon</string>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>org.jenkins-ci</string>
    <key>ProgramArguments</key>
    <array>
      <string>/bin/bash</string>
      <string>/Library/Application Support/Jenkins/jenkins-runner.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>UserName</key>
    <string>jenkins</string>
    <key>SessionCreate</key>
    <true/>
  </dict>
</plist>

一、创建方法传入参数及获取返回参数
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命令

      本文链接:https://www.haomeiwen.com/subject/pzfykctx.html