Hi Ashok
> if I want to go to specific directory in jenkinsfile, how can we write
> groovy script
Jenkins pipeline aka jenkinsfile is a plain text file and does not have directories inside - do I understand correctly that you want to refer to some folder in build area or server/agent file system? I this is what you want then the best option is definition of environment variables in your pipeline/jenkinsfile and using them in scripts/definitions. Jenkins manual (
https://www.jenkins.io/doc/book/pipeline/ ) has detailed information about pipelines.
As to cleaning the workspace: unfortunately, Jenkins plugin does NOT support exclude filter. There are two options:
1. cleanWs call should have an explicit list of the folders to clean - the large number of the folders may be a proiblem
2. Second apporach requires special structuring of the Jenkins build space - the whole area defined for Jenkins build space is organised as set of folders designated for individual jobs ans set of folders that keep data persistent between jobs. For first set of the folders cleanWs can be used without necessity to filter content, for second set of folders you may have a separate housekeeping process. This approach would be my preferred option as it provides greateer flexibility. With this approach you need to have a set of the environment variables that enable the required structuring and access.
Regards,
Nick