jenkins 批量修改配置文件

jenkin job 修改配置

修改前配置

 

 <runPostStepsIfResult>
  <name>FAILURE</name>
  <ordinal>2</ordinal>
  <color>RED</color>
    <completeBuild>true</completeBuild>
  </runPostStepsIfResult>

 

修改后配置

 <runPostStepsIfResult>
  <name>SUCCESS</name>
  <ordinal>0</ordinal>
  <color>BLUE</color>
    <completeBuild>true</completeBuild>
  </runPostStepsIfResult>

 

用sed 修改方法

1、删除 <runPostStepsIfResult> 下面3行

sed -i '/<runPostStepsIfResult>/{n;d}' */config.xml;
sed -i '/<runPostStepsIfResult>/{n;d}' */config.xml;
sed -i '/<runPostStepsIfResult>/{n;d}' */config.xml;

2、在<runPostStepsIfResult> 下面添加3行

sed -i '/<runPostStepsIfResult>/a\ <name>SUCCESS<\/name>\n <ordinal>0<\/ordinal>\n <color>BLUE<\/color>' config.xml;

 

shell脚本

 

cd /app/mount_data/jenkins_home/jobs/
sed -i '/<runPostStepsIfResult>/{n;d}' */config.xml;
sed -i '/<runPostStepsIfResult>/{n;d}' */config.xml;
sed -i '/<runPostStepsIfResult>/{n;d}' */config.xml;
sed -i '/<runPostStepsIfResult>/a\ <name>SUCCESS<\/name>\n <ordinal>0<\/ordinal>\n <color>BLUE<\/color>' config.xml;

posted @ 2017-05-04 21:41  testway  阅读(912)  评论(0编辑  收藏  举报