Situation: you see some folder in a job workspace, like on screenshot below and you want to copy all file names with sizes and mtime data.
Solution: paste the following code into your browser console:
| pipeline { | |
| stages { | |
| stage '1', { | |
| steps { | |
| script { | |
| def userInput = input \ | |
| id: 'userInput', | |
| message: 'Enter urls for Upstream and Mirror repositories', | |
| parameters: [ | |
| string( |
| #!/bin/sh | |
| # shellcheck disable=SC2039 | |
| git-replace-file-with-ignored() { | |
| local fileName=${1?fileName parameter should not be empty} | |
| git config filter.orig.clean "cat %f.orig" | |
| cp "$fileName" "$fileName.orig" | |
| echo "$fileName filter=orig" >> .git/info/attributes |
| String DIR = '/data/jenkins/workspace/UISW-C-UI/Daily/c-daily-build' | |
| void executeInBash(String bashCommand) { | |
| java.lang.Process process = ['/bin/bash', '-c', bashCommand].execute() | |
| process.waitFor() | |
| println process.getText() | |
| } | |
| ////// |
| node { | |
| echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1' | |
| echo 'No quotes, pipeline command in single quotes' | |
| sh 'echo $BUILD_NUMBER' | |
| // 1 | |
| echo 'Double quotes are silently dropped' | |
| sh 'echo "$BUILD_NUMBER"' | |
| // 1 |
| #!/usr/bin/env bash | |
| # 1. Prepare git log | |
| git --no-pager log \ | |
| --pretty=format:%H,\"%ad\",\"%aN\",\"%aE\",\"%f\" \ | |
| v2.42.1..develop \ | |
| > 00-git-log.csv |
| #!/usr/bin/env bash | |
| # shellcheck disable=SC2016 | |
| # List all text files in repo, correctly process file names with spaces, tabs and line feeds | |
| textFiles="$( | |
| git grep --null -I --files-with-matches '' \ | |
| | base64 | |
| )" |
| function(printCommand THE_COMMAND) | |
| message("command: " ${THE_COMMAND}) | |
| foreach(item ${ARGN}) | |
| string(STRIP ${item} stripped_item) | |
| message(" ‘${stripped_item}’") | |
| endforeach() | |
| endfunction() | |
| set(EXE_FILE "printf ") |
| #!/usr/bin/env groovy | |
| void main() | |
| { | |
| def p = 'ps aux'.execute() \ | |
| | 'grep code'.execute() \ | |
| | ['awk', '{ print $1 }'].execute() | |
| p.waitFor() | |
| println p.text |