Reputation: 733
I'm working on R&D project where my idea is to trigger a shell script
from Jenkins
and write the console output I get to a file (text file) placed in a remote windows server. I tried looking for options but none of them were helpful.
Is there any way to write the Jenkins
console output to a text file located in the remote server using:
Is there any connectivity access required to write the output as required? Kindly help me figure out a way.
Upvotes: 2
Views: 10901
Reputation: 733
I found a way for this. We can use the Jenkins REST API and it will help us read the console output and we can write it to a file and do the necessary actions.
Upvotes: 0
Reputation: 527
I can think of several ways to achieve this:
When running your shell command, redirect it to file:
echo scripting output > myScriptOutput.txt
Then copy the file to a remote file share:
copy myScriptOutput.txt \\server\share\subfolder
(can be done in either freestyle or pipeline job).
Redirect output like above, then archive the artifacts, and use one of the Publish Over...Plugins to copy it to a remote server (can be done in a freestyle job only).
Configure your remote server as a Jenkins node. Then, use a pipeline script like:
node("myBuildNodeNameOrLabel") {
bat """echo scripting output > myScriptOutput.txt"""
stash includes: 'myScriptOutput.txt', name: 'myScriptOutput'
}
node("myRemoteServerNodeNameOrLabel") {
unstash 'myScriptOutput'
// copy the file to another local folder outside the workspace
bat """copy myScriptOutput.txt d:\\some\\other\\path"""
}
Same as above, but capture the script output using Groovy then manipulate it...
myOutput = bat returnStdout: true, script: """echo scripting output"""
// now do whatever you want with the Groovy var myOutput...
The Email-Ext Plugin can send Jenkins' Console Output via e-mail.
Upvotes: 2