Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readfile-writefile.txt in Jenkins #113

Open
vinodkumar4b9 opened this issue Feb 2, 2021 · 4 comments
Open

readfile-writefile.txt in Jenkins #113

vinodkumar4b9 opened this issue Feb 2, 2021 · 4 comments

Comments

@vinodkumar4b9
Copy link

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.

@szabgab
Copy link
Owner

szabgab commented Feb 2, 2021

Show me the code you wrote so far.

@vinodkumar4b9
Copy link
Author

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 .

image
image

@vinodkumar4b9
Copy link
Author

Hi @szabgab ,

Any comments on this ??

1 similar comment
@vinodkumar4b9
Copy link
Author

Hi @szabgab ,

Any comments on this ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants