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 25, 2020 in Jenkins by akhtar
• 38,170 points
681 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 25, 2020 by MD
• 95,060 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
• 58,990 points
18,139 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,530 points
1,249 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
9,777 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
949 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,530 points
40,733 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
• 58,990 points
18,385 views