I have .gitlab-ci.yml configuration with:
deploy-integration:
stage: deploy
script:
- cp target/example.war /var/webapps
- service tomcat7 restart
But execution wasn't successful because of:
$ service tomcat7 restart
You need root privileges to run this script
ERROR: Build failed: exit status 1
What's the best way to restart tomcat with gitlab-runner? I want give permission to gitlab-runner just for this one command.
You can add
gitlab-runner
user to sudoers file:to execute the specific command without asking for a password: