How to run a script as root in Jenkins

0 votes

Hi Guys,

I have configured Jenkins on the Linux system. I want to run a script as root in Jenkins. How can I do that?

Oct 26, 2020 in Jenkins by akhtar
• 38,210 points
2,271 views

1 answer to this question.

0 votes

Hi@akhtar,

You need to run the script with Sudo. This will run the script with root privileges.

$ sudo /path/to/script

But before you must allow Jenkins to run the script in /etc/sudoers.

jenkins    ALL = NOPASSWD: /path/to/script
answered Oct 26, 2020 by MD
• 95,300 points

Related Questions In Jenkins

0 votes
2 answers

how to execute a shell script post build step in Jenkins?

You could use the Post Build Task Plugin ...READ MORE

answered Jul 31, 2019 in Jenkins by Sirajul
• 59,070 points
21,065 views
+2 votes
4 answers
0 votes
1 answer

I’m facing a login error when I try to run Jenkins on Docker. How do I solve this?

You have to open the /var/log/jenkins/jenkins.log file to ...READ MORE

answered Jul 24, 2018 in Jenkins by Sophie may
• 10,550 points
1,623 views
0 votes
3 answers

How to get the Maven Version of a project in Jenkins?

Here is a snippet from our Jenkins ...READ MORE

answered Oct 4, 2019 in Jenkins by Petr Doležal
12,765 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
1,288 views
+2 votes
1 answer
+5 votes
3 answers

How to trigger a Jenkins pipeline A in another Jenkins pipeline B?

You can run the following code, its ...READ MORE

answered Jul 5, 2018 in Jenkins by Sophie may
• 10,550 points
60,495 views
+1 vote
3 answers

How to auto build a job in jenkins if there is any change in code on Github repository?

To automatically run build on code commit, follow ...READ MORE

answered Jul 31, 2019 in Jenkins by Sirajul
• 59,070 points
31,427 views