This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def numOfMonths = 4 | |
Calendar calendar = Calendar.getInstance(); | |
calendar.add( Calendar.MONTH, numOfMonths * -1 ); | |
def threeMonthsAgo = calendar.getTime() | |
def filterClosure = { job -> ((job.getLastBuild()?.timestamp?.time?.before(threeMonthsAgo) && job.getLastBuild() != null) | |
&& job.name.toLowerCase().contains('-Branch-'.toLowerCase()) && job.name.toLowerCase().startsWith('MaaS'.toLowerCase()) | |
&& !job.name.toLowerCase().contains('Infra'.toLowerCase()) && !job.isDisabled() ) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The following code replaces a value of a property in a property file, while keeping comments if exist | |
def fileName = 'test.properties' | |
def propertyKey = 'key' | |
def myFile = new File(fileName) | |
def fileText = myFile.text | |
matcher = fileText=~propertyKey+"=(.*)" | |
result = matcher.replaceFirst(propertyKey+'=new value') | |
myFile.withWriter { myFile << result } |
NewerOlder