go-cd

go-cd - run basic linux commands (cd, etc) in GoCD at task level


I have had a good amount of experience using GoCD. I previously used bash scripts to generate builds and was successful as well. For some reason, I have to use basic linux commands as individual tasks.

What I have done successfully:

  1. Pipeline1 - > Stage1 > Job1 > Task 1 : git clone my-project

  2. Pipeline1 - > Stage1 > Job1 > Task 2 : bash my-project/script.sh

What I want to achieve:

  1. Pipeline1 - > Stage1 > Job1 > Task 1 : git clone my-project2

  2. Pipeline1 - > Stage1 > Job1 > Task 2 : cd my-project2

  3. Pipeline1 - > Stage1 > Job1 > Task 3 : build package (*tar.gz file)

  4. Pipeline1 - > Stage1 > Job1 > Task 4 : mkdir newDirectory/

  5. Pipeline1 - > Stage1 > Job1 > Task 5 : mv *tar.gz newDirectory/

Whilst I am able to achieve task 1,3,4; but for commands like cd, mv, I get error like check if agent can run cd, cannot find the file (when I run the mv cmd as it is in terminal it works!) respectively.

I came across GoCD Command Respository, but I am not sure how would it help me. Can anyone help if you faced the same situation earlier?


Solution

  • Just in case anyone was looking for the answer!

    Okay, so I was playing around settings and found the field of 'Working directory' while creating a new task. here you can specify the directory where you want to run your command relative to where git checks out the materials. This serves te purpose of cd.

    Will update this answer when I get something for mv.

    Thanks!