Generate a file as a Release Pipeline's output in Azure DevOps? - tfs

During a Release pipeline I need to download a Storage Table content before deleting the resource, but I don't know which path I can save the files to.
I can't save to another Azure resource, more like a Pipeline output, or like the files generated by the Tests.
I tried saving to something like $(Build.ArtifactStagingDirectory) but no success

You can add a Copy Files task to copy the files to $(Build.ArtifactStagingDirectory) first, then publish them to build artifacts using Publish Build Artifacts task.
You can also copy the files to a file share (UNC path like \\sharefolder) if it's an option.

Related

access jenkins build artifacts in postbuild-plugin

Is there any way to access the previously build artifacts in a post-build-plugin? If yes, how do I access them?
For example:
My build creates a .jar file as an artifact.
In my plugin, I would like to access that .jar file and send it to an external server. That server is going to evaluate the file and depending on the result, I'd like to mark the build as failed/unstable/successful.
All build artifacts are in the workspace, in the same path the previous step saved them, ie build/libs/foo.jar. If you click in workspace, you can find it there, and it would be available for any post-build-plugin if you dont move it or delete it. Post build steps are executed in the workspace so it should be accessible with ie ./build/libs/foo.jar

Where does the jenkins shared library files get stored?

The shared library files in jenkins are loaded at the beginning of the job, where does it get stored? I am trying to access the dockerfile stored in the shared library, I need the path to give in the docker build command. Is there a way I can find out the place where the shared library files are loaded in jenkins?
If the shared library is loaded from SCM and your workspace path is jenkins/workspaces/jobName, then a copy is checked out to jenkins/workspaces/jobName#libs or similar (might be suffixed with a number if that path is occupied by another concurrent build).
However, there is another way, if I understand you correctly you wan't to retrieve a resource in this library? In that case you should use the libraryResource and writeFile steps. Like this:
writeFile file:'myFile.txt', text:libraryResource("path/to/myFile.txt")

Jenkins - how to add additional folder with subfolders, e.g. Images

I have a web project that Jenkins is building perfectly and pushing to Octopus Deploy.
I now have an additional folder, with subfolders, e.g. Images, which I need to include.
This is not directly part of the .net build and we used to copy it manually afterward.
Do I need a specific plugin which I can use to select the folder to include?
Which plugin?
Where in the build process does this plugin run?
The build and deploy to octopus is done in one step -
where do I fit in this additional folder to be included in the push to the octopus?
This is not directly part of the .net build and we used to copy it manually afterward.
If your Jenkins server can access that addition folder in a shared path, add a pre-build step which, as an "Executable Windows batch command" step, would copy that folder into the Jenkins workspace.
No plugin needed here.
Once that is done, you would still need to modify Octopus accordingly, to take into account that new copied folder.
See:
"How to add a folder to a nuspec file"
"How to include directories recursively in NuSpec file"

How to copy the content of sub-dir without a custom Ant task?

I'm working with Jenkins 2 and trying to copy artifacts between jobs and in turn to an S3 bucket.
I have a simple web build which produces artifacts in /dist/public which I'd like to upload into the S3 bucket.
So once the job completes, I have a folder /dist in the workspace root. Jenkins gives you the ability to copy artifacts between jobs which leverages Ant's fileset.
The issue I'm having is that this is a restricted subset of Ant and all you're provided is include & exclude paths.
I can use dist/public/**/** however this copies the parent directories across also.
What I would prefer is to only copy the content of public/ but after doing some reading it seems this may be difficult to do without a custom Ant tasks, etc.
If you copy files by Ant, you should set:
<fileset dir="/dist/public"/>
at you copy task, or you can use flatten attribute.
If you use Jenkins artefact collector (as I do), I think now you have to copy this files to workspace root (see: Copy Artifact Plugin).

How to pass job-specific files to Jenkins as part of job configuration?

I have a jenkins job that pulls source code from GitHub public repo. I need to pass some files such as instance-specific configuration files containing secrets to the job and merge with source code prior to running build because these files are obviously inappropriate to be put in public SCM. The Jenkins instance is a multi-tenanted shared service.
The config files don't change often so I don't want to implement using file parameter which forces user manually input the file on every run. Another reason file parameter doesn't work is some builds are triggered automatically by SCM.
I don't want to use Config File Provider Plugin either, because the plugin requires jenkins admin access but I want users with job-level privileges manage the files themselves.
Ideally the uploaded files are saved alongside with job config.xml instead of in workspace, because I would like to delete workspace after each build. I can write scripts to copy the files from job config folder to workspace.
Are there any solutions available? Thanks.
If the "special" files are being placed in a folder with say some access privileges to it, couldn't you either run a Pre-SCM-Buildstep to move the files with shell commands, or introduce a regular build step (i.e. after the SCM stuff and before the other build steps) that would also use shell commands to move files?

Resources