1

How do I build a meteor app (do 'meteor build .') in a GitLab custom hook? The custom hook is run by the user git who does not seem to have any possibility to run meteor build.

Therefore I want to change the user in the script to someone who is known to be able to build the app.

This is my bash file until now:

#!/bin/sh
#

# The deployed directory
DEPLOYDIR=/var/www/site/

echo " - Starting checkout"
GIT_WORK_TREE="$DEPLOYDIR" git checkout -f
echo " - Finished checkout" 

echo " - Starting meteor build"
#not working yet
sudo su - nodejs
cd "$DEPLOYDIR"
meteor build .
user1255102
  • 171
  • 1
  • 1
  • 4

1 Answers1

1

su - user starts an interactive shell with the user user. You're going to want to use the following:

su -c "cd \"$DEPLOYDIR\"; meteor build ." nodejs

Dissection:

su: su executable
-c "COMMAND": run COMMAND as another user
nodejs: nodejs user

Piper McCorkle
  • 138
  • 1
  • 6