0

I am using two CentOS servers. I am not using any code repository. In Jenkins when I click "New Item," I see no place to enter the target server. I expect a place to configure a target server for a given build (e.g., to run a bash command or transfer a file from the Jenkins server to the target server). Since Jenkins runs as a Jenkins user on the Linux side, it cannot SSH over as root. I'd like to be root and execute a command after a transfer a file over from the Linux server that supports Jenkins. I could do this with native shell commands in the Jenkins' "New Item" Build Steps. There is a free text field for such commands. But I don't know how to interactively respond to the password challenge.

Where do I configure the target server of a given deployment?

Can I hard code the root password into the Jenkins job? If so, how do I do it. I don't want to install sshpass.

Besides having core Jenkins, what plugins are necessary to deploy files from one Linux server to another Linux server?

Kiran
  • 31
  • 2
  • 6

1 Answers1

0

In Jenkins you use labels to define where a project can be built. Once you create a new item you will see (in the job configuration) a checkbox named "Restrict where this project can be run". Here can either use the slave node name (for example slave4.mycompany) or create a label which is a container for multiple slaves. Once properly filled out, this job will always build on the given slave node.

If you need more functionality than that, try the NodeLabel Parameter Plugin (nodelabelparameter). You can install it from Manage Jenkins > Manage Plugins > Available.

To identify which node you are on during the build, you can for instance manually set persistent environment variables on both build slaves, as example $SLAVENAME returning "buildslave1", or use the linux "hostname" command in your scripts to identify the current context, and based on that output decide how to proceed.

pKami
  • 163
  • 6