code-maven.com
code-maven.com copied to clipboard
readfile-writefile.txt in Jenkins
Hi Gabor,
Regarding the Jenkins readfile and writefile , I have a doubt here as By using the script we were able to read the data from a text file and able to print the same , But How can we Pass the values in for Loop and print them in a for loop , I have tried different values but those are printing the values all at a time not according to the loop.
Any suggestions on this is highly appreciated.
Show me the code you wrote so far.
Hi @szabgab ,
I am trying some thing like this
pipeline { agent any stages { stage('Example') { steps { echo 'Hello World'
script {
def browsers = readFile(file: 'repos.txt')
def lines = browsers.readLines()
for (int i = 0; i < lines.size(); ++i) {
echo "${lines}"
}
}
}
}
}
}
I am getting different outputs and as per screen shots attached here , But my main requirement is to get one line at a time in for loop so that I can run required commands over there
Basically In the repos.txt file we have list of repos and i will am getting values from file as per your code , But I wanted to print them in a for loop one by one ,Actually my main requirement was like this
I want to read repo details from that text file and wanted to pass them in for loop and wanted to clone different repos at a time and then need too run checkmarx scan using jenkins pipeline , this is what I am trying to achieve .
Hi @szabgab ,
Any comments on this ??
Hi @szabgab ,
Any comments on this ??