I am facing a strange issue, I have a piece of code written in groovy and contains a shell script to update the values of variables in system.properties file. Most of the times the script works fine, but 20% of the times it deletes all the file content instead of updating the variables
def call(credentialsId, repoName, repoAddress, variableToUpdate, releaseType, BRANCH_NAME, branchToCheckoutInRepo, OS='linux'){
def now = new Date()
sh """
cat system.properties | sed -e 's@${variableToUpdate}=.*@${variableToUpdate}=${BRANCH_NAME}@g; s@releaseType=.*@releaseType=${releaseType}@g; s@lastModified=.*@lastModified="${now}"@g' | tee system.properties
"""
}```