I want to get all files name with some pattern from work-space through jenkins pipeline script.
Get list of pjs files from my work-space and store to array
You can use findFiles:
files = findFiles(glob: '**/.pjs')
Find files in the current working directory. The step returns an array
of file info objects.
These file info objects have name as a property, so you can easily get the name of the files as below:
eg. files[0].name
Note:
Make sure that you in the the correct directory (workspace) using pwd() and dir().
Related
I have automated a build/deploy process in Azure Devops / TFS and would like to scrape a file or folder name as a variable from the source file path that is used for my build artifact.
For example, I might want to scrape the folder name of the folder at the build source path and store it for use in the build #, release #, etc.
I have gone through Microsoft's documentation and I believe the information I'm looking for might be associated with the following... but I can't seem to find the right location.
Release.Artifacts.{alias}.BuildURI #The URL for the build.
Azure pipelines example: vstfs://build-release/Build/130
GitHub example: https://github.com/fabrikam/asp
When I attempt to locate the folder name from the source, I have so far been unable to find it in code.
Sorry, it's not possible to get the source file & folder name/Artifact name from the environment variable.
As of now, you need to specify the Artifact alias name in order to access the artifact related information.
E.g, Release.Artifacts.{alias}.DefinitionName
General Artifact variables
Primary Artifact Variables
Using default variables, you can use the default variables in two ways - as parameters to tasks in a release pipeline or in your scripts. here
I have a seed job in Jenkins to create a job to build the workspace. I want to add the job groovy file from the repository. How do I specify the file path for the grooovy on the seed job build step?
I am trying to add it from the file system on the configuration. I get the error file not found. I have tried adding the complete path and also the name of the file.
I have found the solution for it.
You can specify just the relative path to the workspace to access the groovy files.
I have a spec file in Jenkins uploading artifacts to Artifactory repository path test-local/web/develop/web-DEVELOP-12/ where 12 is the build number from Jenkins.
All artifacts are uploaded under web-DEVELOP-XX. I would like this folder to have the same properties as the artifacts such as vcs.revision, build.timestamp, build.name, build.number. Here I only get those properties in the artifact files under web-DEVELOP-XX folder, but I would like to also have those properties to the folder web-DEVELOP-XX.
Is it possible to do this from Jenkins?
you're correct that currently Properties set using a file spec are not set on the root folder.
you can add (at the end of your current set props) a simple curl command to set the properties on the folder.
For ex, this will set a property a=b on "all-my-frogs" folder under my-local-repo repository:
PUT http://rtserver:port/artifactory/api/storage/my-local-repo/all-my-frogs?properties=a=b&recursive=0
note: recursive=1 will set the properties on all files under the folder as well as the folder itself, so you can consider that as your solution (instead of spec)
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")
In my Jenkins configuration, I have a build.xml file specified as post-build process. This build.xml file specifies the JMeter file (JMX) that I want to run and the location where I want to put the report file (jtl).
The location of my jtl files is c:\inetpub\wwwroot\.jenkins\results\jtl\.
I can see that the timestamp of the jtl file in this location matches the timestamp of my build. However, according to the Jenkins interface, under the category of "Publish Performance Test Result Report", I need to specify **/*.jtl as the JMeter file location.
I did that but my builds keep on failing because I keep getting a message saying No JMeter files matching '**/*.jtl" have been found.
I believe this path needs to relative to the workspace root path.
I have tried using relative path (i.e. ../../results/jtl/*.jtl) and absolute path.
But they all give me saying no Jmeter files matching whatever the path is.
So, just exactly what am I supposed to put there for Jenkins to find my .jtl file?
I'm using **/*.jtl with no issues.
However, the location of the your jtl files is questionable.
Typically, they are found within the workspace of the job.
My workspace structure looks like
results/jtl/*.jtl