Jenkins Artifact Archive

I have a problem archiving a folder path in jenkins. I only want to archive what is in the debug folder of my projects. For this, I use the following.

MyApp1/MyApp1/bin/Debug/* 

When I use this, it will archive what is inside the debug folder, but retains the same folder structure (MyApp1 / MyApp1 / bin / Debug).
If I only need to archive files inside the debug folder (Debug /), what am I doing.

Please advise me.

+8
source share
5 answers

You cannot remove the path prefix using only the archive artifact settings. (Some of the downloadable extensions support this - for example, the Publish over FTP plugin)

If you really need this simple solution, add an additional build step that will copy your Debug folder to the root of the project workspace.

+8
source

A cleaner way could be the artifact production phase configured with the appropriate working directory:

  stage('Release') { steps { dir('MyApp1/MyApp1/bin/Debug') { archiveArtifacts artifacts: '**', fingerprint: true } } } 
+2
source

It is really easy! You can use plugins as " File Operations ". After installing it, you need to add a new "build step" after all the build steps, which is called "File Operations". There are many options as you like. For example, “Rename file”, “Copy file”, “Create folder”, etc.

The option "Copy file" with the "Flatten" switch allows you to copy a file only with its name without specifying a file address. You can use this and copy your files to the root of the workspace and archive them.

0
source

I created a method to achieve this:

 def archiveFilesWithoutPath(globPattern) { def files = findFiles(glob: globPattern) for (def i = 0; i < files.size(); i++) { def file = files[i] def parentFolder = new File(file.path).getParent() dir(parentFolder) { archiveArtifacts file.name } } } 

Is used as follows:

 archiveFilesWithoutPath '**/build/libs/*.jar' 

The only downside at the moment is that you need to allow

 new java.io.File java.lang.String 

and

 method java.io.File getParent 

In the approval of the script.

0
source

If this is Visual Studio, you can read the solution, find the project file, and from there you can find the output directory.

0
source

All Articles