Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins : how to print the contents of a text file to the build log?

I have a non-deterministically working Jenkins build step that prints text. It's multi line and has lots of urls in it. It's a python build step. print("""\ xxxx yyy ") It works many times, but not all the times - it messes up the next step when it fails.

I'm not sure how to debug, but maybe I should just add a step that displays the contents of a text file on the console output log. I can't find such a plugin? thank you!

like image 496
AnneTheAgile Avatar asked Dec 12 '14 22:12

AnneTheAgile


People also ask

Where do I find Jenkins logs on Linux?

The default location for Jenkins logs on Linux is /var/log/jenkins/jenkins.log. To view the log file, open it using a text editor such as Nano: On Windows, Jenkins log files are stored as jenkins.out (console output logs) and jenkins.err (error logs) in the Jenkins home folder.

How do I read a file from a Jenkins file?

In the following Jenkinsfile we have two stages. In the first stage we crete a variable called data that holds some text and the we use the writeFile function to write it out to a file. Then we execute ls as an external program using sh. In the second stage we use the readFile function to read in the content of the file.

Why should I create a jenkinsfile?

Creating a Jenkinsfile, which is checked into source control [ 1] , provides a number of immediate benefits: Single source of truth [ 2] for the Pipeline, which can be viewed and edited by multiple members of the project. Pipeline supports two syntaxes, Declarative (introduced in Pipeline 2.5) and Scripted Pipeline.

How do I run a Jenkins build step from a shell?

If your Jenkins is running on Linux, a simple "Execute Shell" build-step with cat filename.txt will print the file to console If running Windows, an "Execute Windows batch command" build-step with type filename.txt will do the same.


1 Answers

If your Jenkins is running on Linux, a simple "Execute Shell" build-step with cat filename.txt will print the file to console

If running Windows, an "Execute Windows batch command" build-step with type filename.txt will do the same.

The filename path is relative to WORKSPACE

like image 57
Slav Avatar answered Oct 18 '22 23:10

Slav