Each commit to our code result in regression tests and deployment of a war file to Artifactory.
We would like to deploy once a day the last successfully tested war.
What would be the best way to do this? We use Jenkins as our CI tool.
If your goal is to save on storage in Artifactory, I'd suggest setup snapshot cleanup instead. You'll always have couple of last sucessfuly tested wars and you won't polute your Artifactory with too many old snapshots.
Create a second job that copies the latest artifact (Copy Artifact Plugin) from your build job and then deploys the artifact. The second job can be scheduled to run once a day.
Related
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.
I am new to Artifactory and would like to know the below
Suppose Jenkins produces the build artifacts( binary or jar) and is deployed to Artifactory repo and at the same time deployed to Dev environment. How do I move the same artifacts to Test environment? Do I need a new Jenkins job? or it can be moved from Artifactory itself ? how
If i build a project 10 times than 10 artifacts will be produces and latest one can be deployed to DEV env. How do I roll back to earlier version?
Can someone explain how does it works jenkins-artifactory
-Thanks
I've built two jobs in my jenkins instance:
Gradle job builds war task and generates a war file ready to be deployed.
Docker job builds a Docker image from a repository.
Both are working fine. However, the second one depends on the first one. So, Docker job needs to use the last war file generated by Gradle job.
How could I be able to do that?
You can use parameterized job trigger plugin to trigger sub jobs with parameter. You have to do the following to resolve above problem:
Create parent job which will have two sub jobs which you mentioned.
Then trigger first job and archive the artifacts which is war file.
Then pass last trigger build number of first job to second job and start that job. Use Copy artifacts plugin to copy war from first job with specific build number which was passed before starting.
This will resolve your problem!!!
Use a post build task for your first job (Gradle job), just cp the war file into the workspace of Docker job. Then configure Docker job so that it does NOT clean workspace before build. And for the post build action, choose delete workspace after build. This will ensure you will only have the latest war file in Gradle job workspace. Also, you should use post build trigger, if your not using that already.
Good Luck!
I have a release build that compiles and publishes the war file to Artifactory. I'd like to have a manually run parameterized build where I can choose among the release builds that it will then pull that artifact from Artifactory and deploy it. Deployment works fine, it's the choosing I'm having trouble figuring out how to do.
Is there a straightforward way to do something like this?
The closest thing I found was Promoted Build Parameter, but this doesn't seem to give me what I need as I don't know how to translate from what it gives to the file in Artifactory.
Use one script based on Artifactory REST API to fetch the needed artifacts from artifactory server.
In jenkins job, the Choice parameter can be used.
Then in the executed shell script, you pass the parameter to the script to download the artifacts.
It works fine for us.
So I got few separated jobs in Jenkins. The first one gets the project from a Git repository, builds it and produces artifacts. And another one has to copy certificates from the first job and publish them to Artifactory (tried to make it using the Artifactory plugin). But the thing is that the Artifactory plugin's available only in the Build job, there's nothing like "Generic-Artifactory integration" in second job's configuration.
Does anyone know what are the requirements for making the plugin work in the Publish job?
You can write a small shell script leveraging Artifactory REST API and execute it in your second, non-build job.
I have done a similar thing with maven and a zip file. I have deployed a zip with a build step in maven calling a deploy:deploy-file and setting my Artifactory repository in settings.xml and deploying directly on my artifactory repository.