How to copy file from remote host to jenkins server - jenkins

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.

Related

Deploying Jenkins Artifact Built by Another Job

I installed the Deploy Plugin on my Jenkins in order to automate the deployment of my Maven built war packages to Tomcat 7. The problem is that I am able to use the plugin to deploy to a remote Tomcat server only if they are made within the same job that uses the deploy plugin. In other words, I have not been able to set up a standalone job that deploys artifacts made by a different job.
For example, I have a job named pack.foo. It uses the source code in /var/lib/project/module to create module.war and put it in /var/lib/project/module/target. However, because of the Maven version setup, the artifact posted on pack.foo's artifact page is something like module-2.0.0-SNAPSHOT.war.
The only way I am able to deploy module.war is if I add a Post-build Action to pack.foo and specify **/module.war to be a remote Tomcat manager URL (provided I have the manager's credentials in Jenkins config). Then the job's console output logs that /var/lib/project/module/target/module.war was deployed to that URL:
Deploying /var/lib/project/module/target/module.war to container Tomcat 7.x Remote with context
[/var/lib/project/module/target/module.war] is not deployed. Doing a fresh deployment.
Deploying [/var/lib/project/module/target/module.war]
How can I use this, or another plugin, to deploy a WAR artifact that was made in a separate Jenkins job? I would like to have separate jobs for artifact creation and deployment. The plugin wasn't finding **/module-2.0.0-SNAPSHOT.war or even **/module.war built by another job even though there was definitely a file on disk that matched that pattern.
See the paragraph on the Deploy Plugin's page you linked:
How to rollback or redeploy a previous build
There may be several ways to accomplish this, but here is one suggested method:
Install the Copy Artifact Plugin
Create a new job that you will trigger manually only when needed
Configure this job with a build parameter of type "Build selector for Copy Artifact", and a copy artifact build step using "Specified by build parameter" to select the build.
Add a post-build action to deploy the artifact that was copied from the other job
Now when you trigger this job you can enter the build number (or use any other available selector) to select which build to redeploy. Thanks to Helge Taubert for this idea.

How to modify jenkins Web Interface to pick artifacts to publish?

I have an project to upgrade my jenkins. So the problem is I use jenkins plugins called "Publish over ssh". As I read that plugin can publish our artifactory file to another server by ssh connection. But in the configuration it always run after our job finised. So every jobs that I run, always publish to server.
So, I want to ask, how can I pick which build history artifacts that I want to publish? and it can publish when I want to publish. And then I have an Idea to adding button in jenkins web interface, to trigger adding job configuration, build it, and publish it over SSH. But, I don't know how to modify jenkins web interface. My server use tomcat, that run java ".war" file.
So, do you all have suggestion for my problem, how to modify jenkins web interface, or how to pick certain build artifacts?
Thanks...

Is it possible to disable upload of artifacts to TeamCity master?

I have created some build configurations with snapshot and artifact dependencies (to create a build chain). The configurations are executed always on the same agent so upload of artifacts to master is not necessary.
Is that possible in TeamCity? Can I somehow avoid the upload of artifacts to master and rather pass the artifacts directly to the next build configuration in the chain?
Thanks in advance.
Martin
There is no way to disable the upload of artifacts to TeamCity, as build agents are allowed to come and go.
But since v. 8.1, TeamCity build agent caches artifacts while uploading them, so they are not re-downloaded again, when next build starts.

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

Upload multiple Gradle artifacts to Artifactory from Jenkins

My environment uses Gradle for builds, Jenkins for CI, and Artifactory for a repository. I use the Artifactory plugin for Jenkins.
Jenkins successfully builds my main jar file and uploads it to Artifactory. The build script has a second target for creating a distribution zip file under build/distributions. Jenkins creates the zip file successfully, but I don't know how to tell it to upload that artifact to Artifactory, too.
Is this something I should be able to specify in the Jenkins Artifactory plugin config, or something I should define in the Gradle build script? Thanks for any pointers.
You should configure the archives configuration to include all the archives you intend to publish as described in Gradle's user manual. Not only Artifactory will pick up all the files to deploy automatically (without messing with Published Artifacts configuration), you won't even need to run the second task. All the archives will be creating by running the build task.
I assume you have configured artifactory server correctly in Manage Jenkins section; also your job is setup as a Freestyle Project.
Select your job and click Configure. Check Generic Artifactory Integration in Build Environment. Select your Artifactory Server and Target Repository from drop downs, check Override default deployer credentials if required. In Published Artifacts you enter the pattern for your zip file to be published, e.g. ${WORKSPACE}/distr/*.zip (where by WORKSPACE is jenkins current project's workspace and distr/*.zip your distribution zip file). Check if required Capture and publish build info, Include environment variables etc. Save your job. When you build it the next time, the zip file will be uploaded and will be available in the Builds section on artifactory.

Resources