In Jenkins "Publish over Ssh" plugin how do I use the Label(Advanced options) aka Parameterized publishing feature. How do I use the label field. What do I put in the Label field. Do I need to put a variable name(one I can read from build param) that would have the Machine Name . I tried out the same Here is what I did:
I had a machine name QA_1 and I had one variable jenkins build $MC_NAME pointed to XXX . I entered $MC_NAME in the LABEL field. but to my surprise Jenkins was publishing to QA_1 machine irrespective of what the value of $MC_NAME variable.
Can some one PLease tell me the exact steps to control which machine to publish/run scripts by using LABEL filed in "Publish over Ssh" plugin in Jenkins
Answer to your question and how I configured my process:
Publish over SSH section
Username: ec2-user (for amazon)
Click Add Server button
Add Choice Parameter
Choices:
server_1
server_2
Run job and select for example Server => server_2.
You will see in log:
SSH: Skipping [server_1] - Label server_1 does not match expression server_2
SSH: Publishing to [server_2] - Label server_2 matches expression server_2
SSH: Connecting from host [ip-10-0-0-37]
SSH: Connecting with configuration [server_2] ...
The plugin compares the value of the parameter named "Server" (which you selected before job starts) with the labels that you have configured. If label and parameter match, then the SSH commands are executed.
Hope it was helpful. Cause I spent on it 5 hours.
You should enable "parameterized publishing" and specify build parameter name by clicking "Advanced..." button that is last before "Add post-build action" button in your build config (I use post-build actions section for example).
E.g. "build parameter name" = SSH_SERVER
. Then there should be SSH_SERVER
build parameter with regexp to match ssh servers labels.
In your case, SSH_SERVER
build parameter should be set to XXX, after that SSH publishing should happen only for QA_1 server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With