Jenkins : Windows build to Windows host : which plugin to use? - jenkins

I have found many examples of Linux to Windows or OSX to Windows, but battling to find how to copy build files from a Windows server installation of Jenkins, to the
Windows server which will host the website.
I tried Copy Artifact Plugin - but it seems this is used to copy other builds into the current build - is this correct?
Or can it be used to copy the build that just execute to a remote Windows folder?
What should I use to copy to another Windows server?
I would like to not use batch files. Can/should powershell be used?
The idea would be to copy the files to a timestamped folder on the hosting Windows server
e.g.
xcopy *.* \\MyHostingServer\Temp
Then only after everything has copied successfully - to copy the files from MyHostingServer\Temp into the correct web folder. This is to prevent the deployment to the web folder if e.g. network connection was lost halfway.
I am having a really hard time getting Windows specific information.

I suggest to use two jobs:
build job is running on the first Windows server. Archive your build files as an artifacts to the job
deployment job should run on second Windows server. You can use "Copy artifacts from another project" to get your build files locally (on second server)

Related

Jenkins Publish Over SSH: How to give windows directory(Eg: E:\Test\SFTP\In\Test.txt) in Source file and remote UNIX directory in Remote directory

Can some please help me using the directory structure in the Jenkins job for sending files to the remote ssh server?
Jenkins Publish Over SSH: How to give windows directory(Eg: E:\Test\SFTP\In\Test.txt) in source file and Remote directory in unix(/data/xyz/test/sftp/In)
enter image description here
If I understood you correctly, you want to publish a file from your build server (windows) to you remove server (UNIX) ?
In that case you could do the following.
When jenkins builds your package, it will build it in your project workspace folder which is located in your jenkins working directory.
If you want to deploy everything that is on there you can set / in your source files field in which case it will take all files and all directories
and will publish it to the desired path on the remote server. On this example it publishes it to /usr/share/nginx/html but in your case it would be /data/xyz/test/sftp/In
Something quite important, depending on your configuration, sometimes it considers the given path as relative to the jenkins home path so either make ~/data/xyz/test/sftp/In or data/xyz/test/sftp/In.

How can we copy or download files from windows share path(UNC) to linux servers in Azure Devops tool/TFS?

I am trying to copy war and ear files from windows share path(UNC) to linux target servers where jboss jvm is running and then deploy these files using our custom script. this is for applications that are still not using tfs to do their build. i tried download from file share task in azure devops but that is only copying to the agent location but not to the target server. if anyone has come across this situation and found a solution please do share your thoughts. appreciate it. thanks.
You need to use two tasks/steps to handle this situation.
Copy/download files from windows share path(UNC) to a folder path in build agent machine, such as $(Agent.BuildDirectory)
Copy files from a source folder to a target folder on a remote Linux server machine over SSH.
Since you have successfully download from file share task in Azure DevOps to agent machine. Then you just need to use Copy Files Over SSH task.
Use this task in a build or release pipeline to copy files from a
source folder to a target folder on a remote machine over SSH.
This task allows you to connect to a remote machine using SSH and copy
files matching a set of minimatch patterns from specified source
folder to target folder on the remote machine. Supported protocols for
file transfer are SFTP and SCP via SFTP. In addition to Linux, macOS
is partially supported.
More detail configuration about this task please refer official link here-- Copy Files Over SSH task

Artifact "Windows Machine File Copy" task configure properly

I just tried to automate my build process. So tried to add Windows Machine File Copy task for artifact (Release Definition)
This DevOpsBuild artifact has 3 environment as seen on the picture.
So I added Windows Machine File Copy task to copy the files from my published folder
\localhost\NewBuildDropLocation\$(Build.DefinitionName)\$(Build.BuildNumber)/drop/MVCWebApplication/MVCWebApplication
So as example
\localhost\NewBuildDropLocation\DevOpsBuild\20180427.3\drop\MVCWebApplication\MVCWebApplication
here the image of above settings
then after I create release for this artifact, it's stuck "In Progress" phase not going for other phases.
I'm using localhost environment for all these task. I'm newbie to DevOps, followed this tutorial
localhost is the machine the agent is running on.
The source parameter should be the location of the build artifacts, which is usually $(System.DefaultWorkingDirectory), or some subfolder of that. See the documentation for more details.
The Machines parameter should be an actual hostname for a server on your network.
Also note that if you're using the Hosted agent, none of this is going to work -- if you're deploying to on-prem servers, the servers have to be network-accessible by the agent. The hosted agent is run by Microsoft and lives in the cloud and definitely doesn't have access to your servers. You'll need to configure a private agent.

Jenkins service won't start after backup

My organization needs to make backups of our heavily customized Jenkins instance. After doing some research on different methods for backing up Jenkins, we decided to go the route of copying the whole Jenkins directory using xcopy and then moving the backup to a new instance on a different machine. (The reason for using xcopy is that its the only way to preserve they symbolic link files within each job.)
Here's the steps I have taken:
A batch file uses xcopy to copy the entire D:\Jenkins directory on a nightly basis from the old machine
I install a fresh instance of Jenkins on a new server
I stop the Jenkins service from running
I delete the current Jenkins directory in the new machine and then xcopy the backup in its place
I attempt to start the Jenkins service and I am met with the following error:
The Jenkins service on Local Computer started and then stopped. Some
services stop automatically if they are not in use by other services
or programs.
I have tried running jenkins.war from the command line and that just causes a Jenkins instance to start up that doesn't register as a windows service, and I cannot login to (even after disabling useSecurity), and looks like it doesn't have our modifications present.
I have also tried clearing the application log and that did not help.
I am not sure how to get the Jenkins service up and running.
The one folder you need to backup is the one referenced by the environment variable JENKINS_HOME
It is best to keep that folder separate from the installation folder like C:\Program Files (x86)\jenkins.
Then I prefer using a tomcat instance, and copy the jenkins.war in it: it is easier to upgrade:
Simply overwrite your jenkins.war with the new version. Tomcat should automatically redeploy the application.

How can I use MSBuild to deploy to a folder in TeamCity?

On my local dev machine this works perfectly:
msbuild project.name.csproj /p:DeployOnBuild=true /p:DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="c:\proyectos\folder1\deploy" /p:AutoParameterizationWebConfigConnectionStrings=false
I'm trying to configure a Build step in TeamCity with MSBuild, in the "Command line parameters" I'm putting this:
/p:DeployOnBuild=true /p:DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="c:\proyectos\folder1\deploy" /p:AutoParameterizationWebConfigConnectionStrings=false
It runs, no errors are displayed, but files are not copied to "c:\proyectos\folder1\deploy"
Edit: I'm having the same issues with MSBuild on the command prompt, so it's not teamcity. My local dev machine is on windows 7 and the server is windows 2003
Run with /v:d or v:diag to get logging.
(Get it working local first but... In TeamCity, view the agent in the console and look at the agent detail logs for similar such logs (or just pass the same /v: flag to MSBuild via TeamCity))
You'll want to ensure that the user running the "TeamCity Build Agent Service" has write access to the relevant directories.
(FWIW, I believe the LocalSystem account has different group memberships in Server 2003 and Windows 7. We run all of our TeamCity build agents under their own "teamcity" accounts to more explicitly control permissions and allow access to network shares.)
Installing Visual Studio 2010 DOES fix this problem. But, you can also fix it by copying the appropriate build targets to your machine. Typically, on your dev machine they'll be at (Or take away the (x86) for 32 bit machines):
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web
In there you'll find a bunch of Microsoft.Web.Publishing.* targets.
Just copy those over to the equivalent location on your build machine and all will be well.
Installing Web deploy tool through web platform in the server works for me. Actually visual studio installation installs web deploy, It might be the reason why it works for #himinaya.

Resources