Fail A Jenkins Build When Artifatory Plugin Cannot Find All Artifacts - jenkins

I have a Gradle build that runs in Jenkins and Deploys to Artifactory using the Artifactory plugin for Jenkins. Right now if one of the artifacts is missing a message, "Skipping non-existent file ...", is placed in the console output.
Is it possible to fail the Jenkins job if some of the artifacts are missing?
Can I make sure it only deploys to Artifactory if all of the artifacts are present?

Related

Does 'Archive artifacts only if build is successful' set as true means, any artifacts won't be created in Jenkins if build fails?

I am running a an automation script in Jenkins . Does 'Archive artifacts only if build is successful' set as true means, any artifacts won't be created in Jenkins if build fails ? OR does this means the artifacts are created in the specified folder,but they are not saved for later and once delete workspace is run,the artifacts created will be gone forever.
Archiving artifacts in jenkins means that the artifacts will be saved on the Jenkins master (for later usage). Even if the job is finished and the workspace is cleaned.
For example for maven this setting means: if your maven build is successful (no failures) then the created artifacts (jars, wars or an ear) will be archived/stored on the Jenkins master and you can safely clean the workspace.
I don't know mortar but in your case this will probably also mean: if the build is successful on your Jenkins slave, then your Artifacts will be copied to the jenkins master and stored there. If you clean your workspace after the build or just not isn't related.

Jenkins Artifactory Plugin: upload custom files in the middle of the a build

How can I upload files to an Artifactory by Jenkins Artifactory Plugin in the middle of the build? After uploading, the job will trigger another job which will download the artifact from the Artifactory. Arching artifacts in the Jenkins jobs is not an option for me because we should keep artifacts in Artifactory.
I could use curl to upload to the Artifactory, but I need to have old builds discarding (by Jenkins Artifactory Plugin). I could use "Generic-Artifactory Integration" in the jobs configuration, but it uploads only at the end of the job build.
We have used the jfrog cli to do this on generic jobs. Be sure to include the —build-name and —build-number options to have your artifacts collected correctly when the Artifactory plugin publishes the build info.

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.

Not able to download war file from artifactory by the link created in jenkins console output log

I have added Artifactory plugin in Jenkins and was trying to move the build to Artifactory with the help of the Jenkins Artifactory plugin. I have created a sample Maven project.
The build creation is successful and I am getting a URL of Artifactory on console output of Jenkins which tells that my build has been sent to Artifactory. If I am clicking the URL it, I should get my war downloaded but this is not happening. I am getting 404.
I am using Jenkins 1.617 and JFrog Artifactory 3.8.0
If I am using jfrog artifactory 2.6.4 its working but with other release its not working.
below is the log
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /root/.jenkins/jobs/TestJob/workspace/pom.xml to org.ABC/testapp/0.0.1-SNAPSHOT/testapp-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving /root/.jenkins/jobs/TestJob/workspace/target/testapp-0.0.1-SNAPSHOT.war to org.ABC/testapp/0.0.1-SNAPSHOT/testapp-0.0.1-SNAPSHOT.war
channel stopped
Deploying artifacts to http:192.168.X.X:8080
Deploying artifacts of module: org.ABC:testapp
Deploying artifact: http://192.168.X.X:8080/libs-snapshot-local/org/ABC/testapp/0.0.1-SNAPSHOT/testapp-0.0.1-SNAPSHOT.war
Deploying artifact: http://192.168.X.X:8080/libs-snapshot-local/org/ABC/testapp/0.0.1-SNAPSHOT/testapp-0.0.1-SNAPSHOT.pom
Deploying build info to: http192.168.X.X:8080/test/build
I looks like the log output is buggy. The url http192.168.X.X:8080/test/build should, of course, be http://192.168.X.X:8080/test/build.
Please report it in GitHub Jenkins plugin repo.
Thanks!

Publish to Artifactory copied from another project artifacts in 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.

Resources