Publish to Artifactory copied from another project artifacts in Jenkins - jenkins

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.

Related

Nuget.config file setup in Jenkins (From Jfrog Artifactory)

I'm trying to execute Build action for a dot net core application using Jenkins Pipeline (Cloudbees Jenkins). During the build, when the dotnet restore command is executed, necessary dependency has to be pulled from JFrog antifactory. As of now I have created a local repo, Remote repo and also Virtual repo as suggested by JFrog. What steps have to be taken to make the connection and configuration possible (All the way from Jenkins to Jfrog).
Thanks in Advance.
You should be able to use the Jenkins Artifacttory Plugin. Refer this.

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 check which jenkins job is responsible for an artifact upload in artifactory

We have a lot of jenkins jobs (400+). A lot of them are uploading new artifacts to our Artifactory. Most of them are using the Artifactory plugin.
When we use that plugin we can check the 'build browser' in Artifactory.
This will show the jenkins jobs which are uploading artifacts with that plugin. It's clear.
The problem is that we also have some jobs in which case it isn't useful for us to implement the artifactory plugin. Is there a way in Artifactory we can check those jobs?
We want to see from an artifact which is uploaded WITHOUT the artifactory plugin from which jenkins job it's coming from.
Jenkins jobs that use the jfrog cli to upload artifacts can now also publish build info.
From the jfrog cli help
JFROG_CLI_BUILD_NAME
Build name to be used by commands which expect a build name, unless sent as a command argument or option.
JFROG_CLI_BUILD_NUMBER
Build number to be used by commands which expect a build number, unless sent as a command argument or option.
JFROG_CLI_BUILD_PROJECT
Artifactory project key.
JFROG_CLI_BUILD_URL
Sets the CI server build URL in the build-info. The "jfrog rt build-publish" command uses the value of this environment variable, unless the --build-url command option is sent.
Setting these environment vars during the Jenkins job and then calling
jfrog rt build-publish will allow you to connect the jobs to the artifacts.

Show list of released artifactory versions for deploy build in Jenkins

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.

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