I have a log.txt file.The content of the file as below:
Content of the file as below:
properties{
set properties()
}
buildPipeline()
defPipeline(){
execute()
}
Now I have to insert below line just before buildPipeline():
def testbranch= 'feature'
if(env.BRANCH_NAME.startswith(testbranch)){
properties([pipelinetriggers([cron('0 */2 * * 1-5')]),])
}
I tried below .But it is inserting the statements at the end of the file:
sed -i -e "$adef testbranch= 'feature'" log.txt
sed -i -e "$aif(env.BRANCH_NAME.startswith(testbranch)){" log.txt
sed -i -e "$aproperties([pipelinetriggers([cron('0 */2 * * 1-5')]),])" log.txt
sed -i -e "$a}" log.txt
Expected output:
properties{
set properties()
}
def testbranch= 'feature'
if(env.BRANCH_NAME.startswith(testbranch)){
properties([pipelinetriggers([cron('0 */2 * * 1-5')]),])
}
buildPipeline()
defPipeline(){
execute()
}