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

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/

Related

How can I explore Jenkins workspace?

I want to scan file stored in my Jenkins project workspace.
for example, when I make a project named my_project, I will get report pattern from Jenkins like **/report.xml. and to find report.xml file, I will explore in my own plugin.
since when I print pwd on jenkins console, it prints where my plugin written, not jenkins workspace. so I need to know how to explore jenkins workspace in my plugin.
thanks!
If you're asking where your jenkins workspace is, it is in the workspace folder where you can find all your projects. It should be relative to your plugin folder: ../workspace. You can try to change directory using the relative path. Hope this helps.

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.

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/**/*.

Downloading Nexus artifacts to Jenkins Job workspace

I have an use case where I need to download selected jar files from nexus repository to a Jenkins job workspace and run a program over the downloaded jar files. (I Want to use the .class files in the jars)
Is there any Jenkins plugin available for this?
Add a build-step in the job, prior to the one doing the actual work
and use a copy (or ftp) command to get the files.
You could try the groovy plugin and embed a script within your Jenkins job

Can a Jenkins build access the archived artifacts from itself?

I'm using Jenkins and have the "Archive the Artifacts" step at the end of my builds to archive them into a zip file.
Instead of using this step, I'd like to use a script to push the artifacts to a remote server at the end of the build. The server I'm pushing to uses a REST API / HTTP PUT request in a script to upload files.
Note that I'm looking to access the artifact created in the same build. So if I'm on build #5, I want the artifacts from build #5, not build #4.
Is there any way to access this zip file with a script, in the same build that it was created in?
I need to upload this zip remotely and don't want to create another job to do so.
You can install one of the "Publish Over..." plugins to upload your artifacts at the end of a build.
The goal of the Publish Over plugins is to provide a consistent set of
features and behaviours when sending build artifacts ... somewhere.
See also the full list of "upload" plugins for other methods of publishing your artifacts.
Like #Christopher said, you can use any of the Publish Over plugins on the Jenkins Plugins page to upload the artifact to any of the
If you want to access the archived zip file from within the build itself, you can use the following link to access it:
http://<server>/job/${JOB_NAME}/lastSuccessfulBuild/artifact/<artifact name w/folder>
For example:
server = myserver.com
job name = myproject
artifact = del/project.zip
Your URL would be:
http://myserver.com/job/myproject/lastSuccessfulBuild/artifact/del/project.zip
EDIT: Question was changed. In any case, this would work for accessing the artifact of the previous build in the current one.
There is no way that I have found to access the "Archive the Artifacts" package of the build that generates it. This step always occurs last in the build. Accessing the URL prior to the build ending (during the build via script for example) results in a blank zip file. To get around this limitation, I'm making a second linked build job to grab the zip and run my script to deploy it.

Resources