0

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.

1

You can add gitlab-runner user to sudoers file:

sudo nano /etc/sudoers

to execute the specific command without asking for a password:

gitlab-runner ALL=(ALL) NOPASSWD: /usr/sbin/service tomcat7 restart
  • Also changed from "- service tomcat7 restart" to "- sudo service tomcat7 restart" in .gitlab-ci.yml – Justas Mar 20 '17 at 15:06

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.