GoCD Agent how to copy artifact and run command on different folder (outside of agent working directory)

171 views
Skip to first unread message

Hung Nguyen

unread,
Jun 24, 2022, 12:31:08 AM6/24/22
to go-cd

In my "deploy" pipeline, I have pulled the built artifact from upstream pipeline, but the problem is my working directory is different compared to the GoCD Agent working directory, so I can't deploy that artifact to my working dir. Additionally, I must run some command on my working dir after moving the artifact, e.g. `npm run production`.

  • My working dir: `/var/www/vhosts/project`
  • GoCD Agent working dir: `/var/lib/go-agent`

So, how can I copy the artifact to the outside of GoCD Agent and then run some additional commands?

Thanks a lot.

Jason Smyth

unread,
Jun 24, 2022, 2:58:36 PM6/24/22
to go-cd
Hi there,

It seems to be this should be fairly easy to do by simply following the documentation:


If that is not working for you, please let us know what you have tried and what errors you are encountering.

Cheers,
Jason Smyth

Hung Nguyen

unread,
Jun 24, 2022, 8:00:19 PM6/24/22
to go-cd
Hi,

The problem is the project working dir is outside of GoCD Agent working dir, please check the attachment image,

Thank you.

Hung Nguyen

unread,
Jun 24, 2022, 8:11:10 PM6/24/22
to go-cd
Sorry, I missing the attachment image in the previous mail.

Screen Shot 2022-06-25 at 06.58.35.png

Jason Smyth

unread,
Jun 26, 2022, 1:24:11 PM6/26/22
to go-cd
Hi there,

Have you tried using npm's --prefix parameter? I'm not very familiar with npm, but an internet search suggests this as an option for invoking npm from a different location.

Alternately you could write a script that invokes npm and does whatever else you need, check that into source control and pull it into the Agent's sandbox at runtime. This has the added advantage of having your deployment process be less dependent on GoCD.

Hope this helps,
Jason Smyth
Reply all
Reply to author
Forward
0 new messages