Answers: <p>For Windows you could use <code>curl</code> in a powershell prompt:</p>
  <pre><code>curl  ${BUILD_URL}\consoleText -OutFile C:\SomeLocation\SomeFile.txt
  </code></pre>
  <p>For MacOS:</p>
  <pre><code>curl  ${BUILD_URL}/consoleText -o /SomeLocation/SomeFile.txt
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2020-01-28T23:14:39.020Z
Answers: 2021-01-05T19:29:13.623Z
Answers: 2021-01-05T19:29:13.623Z
Answers: Will Brode
Answers: <p>To get the Jenkins console log without curl or wget:</p>
  <pre><code>writeFile file: &quot;jenkins_console_output.txt&quot;, text: currentBuild.rawBuild.logFile.text
  sh 'sed -ri &quot;s/\\x1b\\[8m.*?\\x1b\\[0m//g&quot; jenkins_console_output.txt'
  </code></pre>
  <p>Explanation:</p>
  <ul>
  <li><code>currentBuild.rawBuild.logFile.text</code> will return <a href="https://javadoc.jenkins.io/hudson/console/ConsoleAnnotator.html" rel="nofollow noreferrer">annotated log</a>.</li>
  <li><code>\x1b\[8m.*?\x1b\[0m</code> is a regex expression to match AnsiColorer</li>
  <li><code>sed -ri</code> use regexp-extended and in-place to update the file</li>
  </ul>
  
Answers: CC BY-SA 4.0
Answers: 2023-05-12T11:14:47.760Z
Answers: 2023-05-12T13:02:57.853Z
Answers: 2023-05-12T13:02:57.853Z
Answers: yoann
Answers: <p>if you want just access the log and download it as a txt file to your workspace from the job's URL:</p>
  
  <pre><code>${BUILD_URL}/consoleText
  </code></pre>
  
  <p>On Linux, you can use <code>wget</code> to download it to your workspace</p>
  
  <pre><code>wget ${BUILD_URL}/consoleText
  </code></pre>
  
  <p>The actual log file on the file system is in the Master machine. You can find it under:</p>
  
  <p><code>$JENKINS_HOME/jobs/$JOB_NAME/builds/lastSuccessfulBuild/log</code></p>
  
Answers: CC BY-SA 4.0
Answers: 2019-09-05T21:09:06.730Z
Answers: Also use `$WORKSPACE`.
Answers: Nakilon
Answers: CC BY-SA 4.0
Answers: 2019-09-12T01:29:48.817Z
Answers: Thanks for this. I had to open a full console output via browser, but it was very big, my browser cannot handle it. You can change the last part of the URL from `consoleFull` to `consoleText` as noted above. While the browser is loading it, you can hit `CTRL+S` to save it as a txt file and open it in notepad++.
  
  Or as noted above, use wget or curl which should be available if you have git for windows installed (for windows users).
Answers: thirdy
Answers: CC BY-SA 4.0
Answers: 2019-01-24T13:23:38.720Z
Answers: 2019-01-24T13:23:38.720Z
Answers: Subhash
Body: <p>How can i get the Jenkins console output in a text file?
  I want to share it with someone, is there any way to do it?</p>
  
Comments: CC BY-SA 4.0
Comments: 2022-07-22T01:04:13.837Z
Comments: See also https://stackoverflow.com/questions/37018509/jenkinsfile-build-log
Comments: Axel Heider
Tags: <jenkins>
Title: How can we get the jenkins console output in a text file?
UserDisplayName: Jay
ThreadText: # How can we get the jenkins console output in a text file?
  
  (Asked by: username_0 on 2019-01-24)
  
  How can i get the Jenkins console output in a text file?
  I want to share it with someone, is there any way to do it?
  
  **Tags:** jenkins
  
  > **Comments:**
  > **username_1**: See also https://stackoverflow.com/questions/37018509/jenkinsfile-build-log  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_4 on 2019-01-24. Score: 44 | Accepted answer
  
  if you want just access the log and download it as a txt file to your workspace from the job's URL:
  
  ```
  ${BUILD_URL}/consoleText
  
  ```
  
  On Linux, you can use `wget` to download it to your workspace
  
  ```
  wget ${BUILD_URL}/consoleText
  
  ```
  
  The actual log file on the file system is in the Master machine. You can find it under:
  
  `$JENKINS_HOME/jobs/$JOB_NAME/builds/lastSuccessfulBuild/log`
  
  > **Comments:**
  > **username_5**: Also use `$WORKSPACE`.  
  > **username_6**: Thanks for this. I had to open a full console output via browser, but it was very big, my browser cannot handle it. You can change the last part of the URL from `consoleFull` to `consoleText` as noted above. While the browser is loading it, you can hit `CTRL+S` to save it as a txt file and open it in notepad++.  Or as noted above, use wget or curl which should be available if you have git for windows installed (for windows users).  
  
  ---
  
  ### Answer by username_2 on 2020-01-28. Score: 4
  
  For Windows you could use `curl` in a powershell prompt:
  
  ```
  curl  ${BUILD_URL}\consoleText -OutFile C:\SomeLocation\SomeFile.txt
  
  ```
  
  For MacOS:
  
  ```
  curl  ${BUILD_URL}/consoleText -o /SomeLocation/SomeFile.txt
  
  ```
  
  
  ---
  
  ### Answer by username_3 on 2023-05-12. Score: 2
  
  To get the Jenkins console log without curl or wget:
  
  ```
  writeFile file: "jenkins_console_output.txt", text: currentBuild.rawBuild.logFile.text
  sh 'sed -ri "s/\\x1b\\[8m.*?\\x1b\\[0m//g" jenkins_console_output.txt'
  
  ```
  
  Explanation:
  
  * `currentBuild.rawBuild.logFile.text` username_2 return [annotated log](https://javadoc.jenkins.io/hudson/console/ConsoleAnnotator.html).
  * `\x1b\[8m.*?\x1b\[0m` is a regex expression to match AnsiColorer
  * `sed -ri` use regexp-extended and in-place to update the file
  
  
  ---
  
  