Execute cmd file on windows deployment server from Jenkins linux server - jenkins

We have one Jenkins master (Linux) and one Jenkins slave (windows). We are working on .NET Web application.
Initially our deployment was to prepare the artifacts through TeamCity and invoke a cmd file manually in the deployment server and the deployment happens. The cmd file invoke nant internally and deploy the all required things.
Now we are using Jenkins to implement the CI/CD pipeline.
We have been able to successfully prepare the artifacts and also copied the artifacts to the deployment server through Jenkins. Build and artifact preparation are happening at Jenkins slave.
Pending is , we just need to execute the "cmd" file in the deployment server.
Can anyone please guide me, how to execute the "cmd" file in the deployment server from Jenkins ?
We are using Freestyle project in jenkins.

First install & configure a Jenkins agent on the deployment server(install, configure)
After selecting your build node:
Open the dropdown in the build section and click on Execute Windows Batch Command:
After selecting the option, a box will appear to enter the commands.

Related

How to deploy a jar on Windows server through Jenkins job?

We have a jenkins job which is getting triggered after every push to gitlab.
It creates a build. Upon successful build we want to copy the jar to some Windows server.
We are able to set SSH credentials for Linux server. How do we do it for Windows server.
Thanks
Install the slave on windows machine & trigger the .bat file through jenkine's job.

Execute Shell script from workspace on remote machine after build successful (Jenkins)

The scenario is - I have a job A which runs my ant script and packages the artifact's for me.
I am also using parametrized Triggered plug in to Trigger my "Job B" which will deploy my artifact on remote machine.
The job A is working fine and also Job B.
The tasks that i have to perform with Job B are
GIT checkout (which contains my deployment scripts) (successfully doning).
Copying artifacts from previous build to Remote machine. (successfully doing)
Run shell script on remote machine(script present in workspace folder )- Facing issues.
I browsed various plug ins for the same but no one is allowing me to run shell script after , "SCP to remote machine" which is present in Post build action.
I would like to execute the same sequence, however if you guys have any other suggestions please share.
Thanks in Advance.!
As part of Publish Over SSH Plugin, you can execute a script after the files had been copied over.
Under Post-build Actions
Add Send build artifacts over SSH
Select a preconfigured server (done in global configuration)
Select files to copy from workspace
Enter Exec command
If one of the files you copy is your shell script, you can enter it here as an "exec command"
To solve my query i used Jenkins SSH Plugin. This provides a configuration tab where i can add multiple hosts and after that used them in my job level configuration.
Link to Plugin
you get privilege to execute shell script on remote host as pre-build step or post build step.
updated the path of publish over ssh it worked for me

Jenkins- Create Jobs on different servers

I want to configure Jenkins to build my code on 1 server. Then want to deploy it on another server using Jenkins.Both servers are using Linux I want to automate the entire process as much as possible. I went through some of plugins like pipeline, Job Import Plugin, etc
Can anyone guide me how to go about it ? Which plugins will be useful ? Any example or tutorial somewhere will be useful. The configuration of build pipeline plugin on jenkins was not seamless for me.
Thanks,
Bhargav
I would work it this way :
Install jenkins on your first server
Install the following plugins : ssh credentials, ssh slaves, copy to
slave, and restart jenkins
Go to Manage jenkins -> Manage credentials, and add ssh credentials
for your second server
Go to Manage jenkins -> Manage nodes, and create a passive slave.
The launch method should be "Launch slave agents on Unix machines
via ssh". You should use the credentials that you have added in step
3
Create a job to build your code. In the advanded options of job, you
should indicate that the job must only be built on master node.
Create a job to deploy your code on the second server. In the
avanded options of job, you should indicate that the job must only
be built on slave node.
In the "Build Environment" section, check the "Copy files into workspace before building" box and configure what files you want to copy from first server (https://wiki.jenkins-ci.org/display/JENKINS/Copy+To+Slave+Plugin)
The code will be copied into the jenkins slave's workspace.

How to copy file from remote host to jenkins server

I am using jenkins for build process. I am running some scripts on remote server using jenkins server. It's fine but remote host generates some html file. I want to copy that file back to jenkins server. Is it possible to do it from jenkins server?
If you want to archive it permanently, you can use the Archive Artifacts option in the Post-build step in Jenkins. In the case of builds that happen on slaves, Archive Artifacts copies the artifacts back to the Jenkins server for archiving and reuse.
If you want to then use this in a subsequent build, you can use the Copy Artifacts step to introduce an artifact from another build into your subsequent process on any Jenkins slave.
We use this to move production builds into our test environment after packaging and it works great.
Copy to slave plugin also copies files back from slaves to the master. Might be worth the look.

Jenkins upload slave build to a server from master

Jenkins is running in a windows machine.
Slave is a mac building iPhone apps. (using ssh)
This configuration building successfully.
If I archive the artifact (e.g. Output/.) it saves in the master (windows machine).
But when I try to run any bat command to copy files in the post build steps, it runs in the slave machine.
How can I run command in the master (Windows), in the post build steps? Or there is other ways to do it?
I want to upload the build artifact to a server accessible only from the windows (master) machine. How can I do that?
How to tell Jenkins, to take the build artifacts from the slave and run some command (copy files) on those files in the master.
Use the Publish Over FTP Plugin. Create an ftp in master and using Publish Over FTP Plugin, copy the build artifacts to master machine.
Thanks,
Manu

Resources