My task is to pull code from Bitbucket and check whether there are any new files commited or any files modified from last commit. If any chamges are available I need to copy the file name and path to a .csv files. Below commmand will check the diff and copy to .csv files. But same activity needs to happen via Jenkinsfile pipeline.
git diff --name-only --diff-filter=M @~ > list.csv
Jenkinsfile script:-
#!groovy
void Download_Repositories(){
checkout([
$class: 'GitSCM', branches: [[name: '*/master']],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'code']],
userRemoteConfigs: [[url: '[email protected]:org-dev/master.git',
credentialsId:'service-user']]
])
}
pipeline {
agent { label 'LABEL' }
// triggers { pollSCM('*/5 * * * *') }
stages {
stage('Download Repositories') {
steps {
Download_Repositories()
sh '''
ls -ltr code/playbooks/
git diff --name-only --diff-filter=M @~ > list.csv
'''
}
}
}//stages
}//pipeline
Error:-
usage: git diff [--no-index] <path> <path>