1
In Jenkins I’m trying to read a file with groovy and for each line check if it contains any of the information I need.
Given the following content of arquivo
:
amarelo
verde
vermelho
azul
The code I have is this:
new File(arquivo).eachLine {
linha ->
contemInformacao(linha, "azul")
contemInformacao(linha, "vermelho")
contemInformacao(linha, "verde")
contemInformacao(linha, "amarelo")
}
def contemInformação(linha, informacao) {
if (linha.contains(informacao)) {
echo "SIM"
}
}
The expected result would be:
SIM
SIM
SIM
SIM
But it’s printed SIM
only once.
I think the function contemInformacao
is being called only the first time.
Does this actually happen? If yes, how can I get her to be called again for each line?