How to upload a complete directory hierarchy structure to artifactory using Jenkins? - jenkins

How to upload a complete directory hierarchy structure to artifactory using Jenkins?
I have a workspace folder with all the artifacts, organized in subdirectories.
How can I keep the hierarchy structure in the artifactory?

You should use the Jenkins Artifactory Plugin https://wiki.jenkins.io/display/JENKINS/Artifactory+Plugin together with a file spec to define the Artifacts that need to be uploaded. In the file spec docs https://www.jfrog.com/confluence/display/RTF/Using+File+Specs#UsingFileSpecs-UploadSpecSchema pay attention to the "flat" and "recursive" options as you probably want to set flat to false.

Related

Is there any way to get Jenkins artifacts in Gitlab pipeline?

Basically the opposite of this question: Is there any way to get Gitlab pipeline artifacts in Jenkins?
My project is built on Jenkins. It generates a JavaDoc.
I want to publish this JavaDoc as a Gitlab Pages.
So I would need my gitlab-yml to be able to retrieve the produced javadoc from Jenkins.
Alternatively, my artifacts are stored on a network drive, so an access to this network drive would work too
I think that this plugin could be helpful to you...
There is a plugin called Archived Artifact Url Viewer. It seems to be like you needs.
"Jenkins plugin to view contents of a file inside a zip or jar file under a subdirectory of artifacts directory of a build The url to access a file inside a zip or jar archive within the artifact folder of a build is as follows"
/archivedArtifacts/artifact/<job_name>/<build_number/<relative location of zip or jarfile within artifact folder>/<location of file within archive>
Ex:
http://<jenkins_url>/archivedArtifacts/artifact/Build%20-%20Dev/10526/junit-logs.zip/junit.log
https://plugins.jenkins.io/archived-artifact-url-viewer/

How to rename existing folder while uploading generic artifacts to JFrog Artifactory in jenkins pipeline

I am using jenkins pipeline. The folder which needs to be uploaded to Artifactory is generated in the *.tar.gz format. Everytime after Jenkins build, the folder name remains same, no change in folder name.
For generic Artifactory integration I don't want to override the previously uploaded *tar.gz. Want to know if tar.gz can uploaded in the incremented order based number/date/time.
Basically you can change the path where you are generating your artifacts (*.tar.gz), lets say give the path as below:-
$BRANCH_NAME/$BUILD_ID/*.tar.gz
It will upload the artifacts with the same name, but will be separated using $BRANCH_NAME/$BUILD_ID.

How to update Artifact Build Module ID

I am using Jenkins CI(single pipeline Job) to push different files to JFrog Artifactory.
For each and every build I am publishing the build info to Artifactory. But every build has same Module ID.
for example: In Artifactory Repository Browser select any artifact then go to Build tab, then it is showing all builds instead of respective artifact build information
So I would like to know how to modify the Artifact Module ID while publishing the artifact information to Artifactory
The build information and Artifact storage are to different mechanisms. The build information is only associated with artifacts in the sense that you can define what artifacts are produced from a build and what artifacts are a dependency of a build. The module ID has no association with the build info. The module ID is defined by the repository layout where the Artifact is stored. See the jfrog documentation here: https://www.jfrog.com/confluence/display/RTF/Repository+Layouts
You cannot change the module ID. Artifactory assigns a module ID based on the repository layout. This means the path to the artifact matters for defining the module ID.
For example the repository layout
[org]/[module]/[module]_[base_rev].[ext] will give module IDs to any artifact stored following that pattern as [org]:[module]:[base_rev].
Artifacts are associated to builds by both a build.name, build.number property on the artifact and publishing a build info from a .json file. The .json must include a section denoting what artifacts were produced from the build.
In general, it sounds like you need to ensure each artifact is being deployed to a unique path in artifactory with the build.name and build.number property being set. The other thing to look at is the file hash. it must match in the build info being published. So if the file hash is not different that means there is no change to the artifact from the previous build.
I don't know how much this will help, but there is a lot of nuances that go into getting the artifacts and builds to line up. You mentioned using Jenkins, have you looked into using the Jenkins Artifactory plugin. It should take care of a lot of this work for you, although we use Bamboo, so I am not as familiar with how it differs.

Download full workspace from Jenkins build

I am new to jenkins and I have tried downloading a zip archive of this workspace in jenkins, but I only get a part of it. Source folders like tensorflow or tools are not present inside the archive. Is this normal ?
If so, how do I get all of them inside a zip file ?
Use Archive Artifact plugin, to add your workspace into archive folder which will make it easily down-loadable.
But be aware that, an artifact in the Jenkins sense is the result of a build - the intended output of the build process.
A common convention is to put the result of a build into a build, target or bin directory.
The Jenkins archiver can use globs (target/*.jar) to easily pick up the right file even if you have a unique name per build.
putting a complete workspace into it will take lot of time.

Resolving Artifacts using Jenkins job with the parent directory

I am looking to download the artifacts using Jenkins job to resolve the artifacts from Artifactory. Specifying the file type and the path to the artifact works, However, unable to resolve all artifacts from the root directory.
Actual Artifactory Path:
repo_key:Group/Artifact/Version/path/to/artifact1/file.zip
repo_key:Group/Artifact/Version/path/to/artifact2/file.zip
Below Configuration in Jenkins job to Resolved Artifacts doesn't works:
repo_key:Group/Artifact/*=>Output
How do I download all files under the Artifact directory to the Output directory.
You need to use the format JBaruch mentioned and add the build metadata as matrix params, to support wildcard resolution for multiple files.
For instance:
repo_key:Group/Artifact/**/*#publishing_build_name#LATEST
Will get you the latest artifacts published by the job "publishing_build_name".
There's some helpful information and examples when clicking on the Question Mark next to the "Resolved Artifacts" field.
Artifact/* will resolve files, directly located under Artifact directory (and there are none). What you need is Artifact/**/*.

Resources