0

1) I have cloned a bitbucket repo name myrepo which has 5 folders..branch name is development.

2) In all 5 folders (A,B,C,D,E) I need to view A folder contents using jenkins pipeline so that the user will have choice to pick/select.

3) All files names should be shown as xxx only not as xxx_yar.yaml.

I have implemented one func which clones bitbucket repo and executing shell command to find A dir and removing _yar.yaml and getting output as xxx.

Here the problem is I am not able to switch from myrepo folder to A folder to execute shell command:

 def CREDS="xxxxxx"
 static void clonerepo(CREDS) {
     def git branch: "development",
             credentialsId: "${CREDS}",
             url: "https://bitbucket.com/xxx/xx/myrepo.git"
     sh(find A -type f -maxdepth 1 | cut -d "/" -f 2 | sed -e "s/_yar.yaml//g")
 }

After this in pipeline question I have given in below format

  MYNAME=input( id: 'userInput', message: 'What is the application?', parameters: [ [$class: 'ChoiceParameterDefinition', choices: clonerepo, description: '', name: ''] ])

so that in above choices all A files contents will be shown to user.

juuk
  • 5
  • 3
  • 1
    Possible duplicate of [Jenkins pipeline how to change to another folder](https://stackoverflow.com/questions/52372589/jenkins-pipeline-how-to-change-to-another-folder) – Mostafa Hussein Jan 14 '19 at 15:55
  • @MostafaHussein will this work? dir("myrepo/A") { sh "pwd" } Above sh command i need to place or what? – juuk Jan 14 '19 at 16:07
  • Yes it will work, `dir` takes a parameter which should be the directory you need to move into it, then you can execute commands inside this directory like using `sh` – Mostafa Hussein Jan 14 '19 at 16:09

0 Answers0