def findAndStageNotIgnoredFiles()

in jenkins-pipeline-shared-libraries/vars/githubscm.groovy [464:480]


def findAndStageNotIgnoredFiles(String findNamePattern) {
    // based on https://stackoverflow.com/a/59888964/8811872
    sh """
    find . -type f -name '${findNamePattern}' > found_files.txt
    files_to_add=""
    while IFS= read -r file; do
        if ! git check-ignore -q "\$file"; then
            files_to_add="\$files_to_add \$file"
        fi
    done < found_files.txt
    rm found_files.txt
    if [ ! -z "\$files_to_add" ]; then
        git add \$files_to_add
    fi
    git status
    """
}