Jenkins switch build folder - jenkins

I'm not even sure if I'm thinking about this correctly so I'm having difficulty googling it. I've got Jenkins set up and building a site and correctly sending the build artifacts over SSH to the live server.
My ideal workflow would be to ssh into the server, drop the new assets into a build folder, copy the old build files to a backup directory and drop all the new build files where the old build files used to be.
Not sure if that even makes sense or if there is a better way to do this. To be clear, I'm not talking about a single .war file or anything. I'm talking about a package of PHP files, images, CSS and other stuff.
I'm new to Jenkins in general so any help pointing me in the right direction is greatly appreciated.

See the ArtifactDeployer Plugin:
ArtifactDeployer plugin enables you to archive build artifacts to any remote locations such as to a separate file server.
...
ArtifactDeployer is a complete alternative to the built-in Jenkins feature "Archiving artefacts' and it is aimed at providing an uniform deployment mechanism.
Add it to your project's config with Post-build Actions → Add post-build action → [ArtifactDeployer] - Deploy the artifacts from build workspace to remote locations.
or the Flexible Publish Plugin:
...
[Send build artifacts over SSH]
...
Add it to your project's config with Post-build Actions → Add post-build action → Flexible publish.
or an idea I haven't tried myself yet, so no guarantees:
Configure your live server to be Jenkins slave node, create a project that is bound to this slave and use the Copy Artifact Plugin therein:
Adds a build step to copy artifacts from another project.
Add it to this project's config with Build → Add build step → Copy artifacts from another project.

Related

How to archive all the build versions (Artifacts) in target folder

Each time i generate my build through jenkins, my existing jar file in the target folder is overwritten by maven. For example: i have a existing version of 1.0 in jenkins target folder, now if i create a new build with version 1.1, the previous version in my target folder gets overwritten.
I don't want that to happen, i want to archive all the versions (because we might provide some of the old features to certain set of customers). i am just trying to understand is there way to do this in jenkins pipeline. I don't prefer plugins, it would be nice to do it declarative way using jenkins file.
First of all, it's not the best solution to store your artifacts just in target folder without any copying to other place. Usually all needed build artifacts are stored in Nexus or Artifactory repositories (of course, you can copy them to some local directory also). You can do that in pipeline Jenkinsfile as well, but you still require to install needed plugin. For example, for publishing artifacts to Nexus repo, you can use Nexus Platform Plugin, see this answer for details.
About overwriting your target folder, I'm not sure if it's cleaned by Jenkins by default. To clean workspace, you need to specify Discard old builds option in job configuration first.
Seems to be that you just execute mvn clean ... command, that's why target folder is cleaned, so I would recommend to check that first.

How to keep artifacts directory during the multi-configuration build in TFS?

I have a solution with multiple projects where some are web apps. I have set up a multi-configuration build in TFS vNext that builds the single app, creates an MSDeploy package, gets the proper staging configuration files and add or replaces the files in the package archive file.
I'd like to use the deployment files created as artifacts to be used in a Release Management pipeline. The problem is that the artifacts directory is purged before each build (i.e. build of a web application). At the end, only the artefacts of the last app that was built are left there.
I can certainly configure the step to copy the artifacts somewhere else, but then the question is how to delete it only at the very start of the build (and by that I mean the build of all projects).
Is there a way how to disable purging of the artefacts directory or how to perform an operation only at the beginning of the build? Has anyone similar experience?
Use the "Publish Artifacts" task to store the artifacts in a UNC location or in TFS itself so they're available for release.

How to enable Artifacts link

I have a TFS2015 build definition: after the build step I have a PowerShell step which is publishing the build artifacts.
How can I enabled the Artifacts link in the build summary?
I've noticed that the Artifacts link is visible only when I have a Publish Artifacts build step in the build definition. I can't use this step because I need a specific folders structure in the build drop folder.
The easiest thing might be to use your PowerShell script to prepare your drop as normal but then add the Publish Build Artifacts task so that the artifacts tab of the release is populated.
The example in this article uses $(build.stagingDirectory) to order the files and then specifies that directory in the Copy Root field of the Publish task.
http://www.codewrecks.com/blog/index.php/2015/06/30/manage-artifacts-with-tfs-build-vnext/

Jenkins ArtifactDeployer simple creates a new dir in base dir?

I am in Jenkins and using ArtifactDeployer. The console output tells me that the remote repo is http:// myrepo but all it does is create a new folder in my base directory which I also specify in this plugin. It correctly finds only one file to copy but strangely just creates a new directory and copies it in there. I thought this would enable me to deploy artifacts to another server... Can I do that?
No you can not do that with artifacts deployer but there are other ones you can use - read below:
Jenkins provides by default a feature for archiving artifacts generated by the build of a Jenkins Job. These artifacts are archived in the JENKINS_HOME directory. However, this directory contains also tool configurations (global and job configurations). Therefore, there is no separation between infrastructure data, jobs data and generated elements. It is often considered to be a bad practice and it doesn't help to manage it from an administrator point of view.
Unfortunately, it's not possible to extend the 'archived artifacts' feature to archive artifacts in a location other than JENKINS_HOME.
The main goal of the ArtifactDeployer plugin is to archive artifacts in your desired locations (other than JENKINS_HOME directory).
There are many Jenkins plugins close to ArtifactDeployer such as CopyArtifact plugin or CopyArchiver plugin for publishing artifacts from Jenkins resources (from the current workspace, from the old builds of the same job or other jobs, ...) to remote locations with the protocol file://
There are also others plugins for managing other protocols such as ftp://, ssh:///.

Plugin to Copy Files from Desktop to Jobs Workspace in Jenkins

I have a scenario wherein the users who have created some configuration files need to upload the same from the desktop where they access Jenkins onto the Job's workspace to build and execute tests.
So I did try using the Config File Provider plugin as mentioned in https://wiki.jenkins-ci.org/display/JENKINS/Config+File+Provider+Plugin. This seems to work fine to copy the configuration file to the Jenkins UI, which can be later synced to the Slave with the given path in the Build environment of the respective job. But the users who wish to upload these files don't have the administrative rights. Hence they are unable to access the Configuration File Management which is under the Manage Jenkins tab. Is there any way that I can move the Configuration File Management under the Jenkins sidebar and allow users to edit the same.
Are there any other plugins that will help me achieve the same? I did also try Copy to Slave plugin but this only copies the files under $JENKINS_HOME/userContent to the job's workspace. We will have to copy the files from the desktop to $JENKINS_HOME/userContent and then use the plugin.
Wouldn't using a parameterized job and have one of the parameters be a File Parameter? See https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build

Resources