Is there a plugin to get Folder path as parameter in Jenkins? - jenkins

I wanted to allow users to select a folder path as a parameter and get the entire folder path as the parameter value. Is there any plugin for this purpose.
I have explored the File Parameter, this allows to select a file path and gives only the file name as output and not the path.
I also explored the File systems object parameter list, this is used to list the folders inside a file as choices.

Have you tried using a String parameter for it? I have several pipelines where I have paths defined as string parameters for use in shell scripts.

Are you sure Filesystem List Parameter can't be conigured to meet your needs?
I believe Extended Choice Parameter should allow you to do this. You'd have write as custom groovy, which could be tricky or take time to load.
You could maybe (request) enhance the Filesystem List Parameter plugin

Related

GCS and Java- Concatenate dynamic bucket name and file name in TestIO

I want to write a file to a GCS bucket. The bucket path and file name are dynamically provided in two different pipeline options. How can I concatenate those in TextIO to write the file to the GCS bucket.
I tried doing this but no luck.
o.apply("Test:",TextIO.write()
.to(options.getBucktName().toString()+options.getOutName().toString()));
where getOutName = test.txt
and getBucktName = gs://bucket
Edit: Options are ValueProvider
We have faced a similar situation in Dataflow Templates, and we have created DualInputNestedValueProvider to address this.
You can feed it with 2 ValueProviders (it could be RuntimeValueProvider and a StaticValueProvider, in your case), and a function to map them to a new ValueProvider.
Take a look here for an example.
By "dynamically provided" do you mean those options are runtime ValueProvider instances? If so, I don't think it's possible to express what you want, since there's currently no hook for combining value providers (per related question).
If these are not value providers, then the example you show should work fine (although missing a / between the bucket and path as written).
Can you share more about how the options are defined?

how to find and deploy the correct files with Bazel's pkg_tar() in Windows?

please take a look at the bin-win target in my repository here:
https://github.com/thinlizzy/bazelexample/blob/master/demo/BUILD#L28
it seems to be properly packing the executable inside a file named bin-win.tar.gz, but I still have some questions:
1- in my machine, the file is being generated at this directory:
C:\Users\John\AppData\Local\Temp_bazel_John\aS4O8v3V\execroot__main__\bazel-out\x64_windows-fastbuild\bin\demo
which makes finding the tar.gz file a cumbersome task.
The question is how can I make my bin-win target to move the file from there to a "better location"? (perhaps defined by an environment variable or a cmd line parameter/flag)
2- how can I include more files with my executable? My actual use case is I want to supply data files and some DLLs together with the executable. Should I use a filegroup() rule and refer its name in the "srcs" attribute as well?
2a- for the DLLs, is there a way to make a filegroup() rule to interpret environment variables? (e.g: the directories of the DLLs)
Thanks!
Look for the bazel-bin and bazel-genfiles directories in your workspace. These are actually junctions (directory symlinks) that Bazel updates after every build. If you bazel build //:demo, you can access its output as bazel-bin\demo.
(a) You can also set TMP and TEMP in your environment to point to e.g. c:\tmp. Bazel will pick those up instead of C:\Users\John\AppData\Local\Temp, so the full path for the output directory (that bazel-bin points to) will be c:\tmp\aS4O8v3V\execroot\__main__\bazel-out\x64_windows-fastbuild\bin.
(b) Or you can pass the --output_user_root startup flag, e.g. bazel--output_user_root=c:\tmp build //:demo. That will have the same effect as (a).
There's currently no way to get rid of the _bazel_John\aS4O8v3V\execroot part of the path.
Yes, I think you need to put those files in pkg_tar.srcs. Whether you use a filegroup() rule is irrelevant; filegroup just lets you group files together, so you can refer to the group by name, which is useful when you need to refer to the same files in multiple rules.
2.a. I don't think so.

parametrized jenkinsFile : file parameter

I want to configure a parametrized job in jenkins, who manipulate file:
parameters([
file(defaultValue: 'DEFAULT', name : 'tomcatCodesUrl' , description: 'URL of service where to find tomcat mapping json file'),
the issus is , this parameter only return the name of the file. how can I acces to this content?
Currently there is no easy way to do this. You can find discussion about this in JENKINS-27413
Yeah that parameter is as redundant as it can be. Might aswell just use string.
Anyway. You can get the files content with readFile:
def content = readFile encoding: 'utf-8', file: 'tomcatCodesUrl'
How to use file parameter in jenkins
This post might be helpful. The upshot is, when users upload a file, it will be saved into the root directory of the project's workspace. You can directly access the file using any programming language you like, given the file name. The file content is not returned to you as a parameter, but anyway, since you know its saved place (workspace dir) and file name, you are in control.

How do I find a particular sub directory using Ant and then use it to create a symlink?

I need to create a symlink to a sub-directory using Ant. The issue is that I don't know where the target sub-directory is.
To create a symlink with ant I do this:
<symlink link="${parent.dir}/FOO/linkname" resource="${parent.dir}/BAR/target"/>
But I don't know what BAR is called in advance so I need to do a search for "target" under parent.dir and then pass the one result into the resource.
Is this possible using fileset? Or another way?
It might be possible to use a fileset but that might give you several symlinks or none.
A much better approach is to define the path to BAR in a property. If there is a dynamic part in this path, change the code so that Ant evaluates the dynamic part and everyone else uses Ant's value.
The typical example here is that the path contains a version or timestamp. Define those in your build file so you can use them everywhere. If a Java process needs the values, pass them to the process as a system property (-D...).

Custom Action in Deployment Project - prompt user for values, and then extract them from custom actions?

I am building a Windows Service which will be deployed on four servers. My user wants to have the service read a configuration file from a common location, and load it OnStart.
I want the installation to prompt the user for the file path and file name to the configuration file when the service is installed, and then save that data in My.Settings.
I have figured out how to set the EDITA1 and EDITA2 variables in the Deployment project's UI, so that the user will be prompted for path and file name, but I don't know how to get those values out and into the settings of the service.
Help, please.
-Jennifer
Did you try passing it to the custom action using CustomActionData Property in the Custom Action property window. syntax is /param=[EDITA1]
Context.Parameters will contain a dictionary with 1 entry key being "param" (in my example above that's the key I gave it).
I'm having a problem with passing in parameters which contain spaces. the guidelines say:
For custom actions that are installation components (ProjectInstaller
classes), the CustomActionData property takes a format of /name=value.
Multiple values must be separated by a single space: /name1=value1
/name2=value2.
If the value has a space in it, it must be surrounded by
quotes: /name="a value".
Windows Installer properties can be passed using the bracketed syntax:
/name=[PROPERTYNAME].
For Windows Installer properties such as [TARGETDIR]
that return a directory, in addition to the brackets you must include quotes
and a trailing backslash: /name="[TARGETDIR]\".
When I try the "[EDITA1]\" for the file path I need.. I get the 'FileNotFound' error for "C..\Microsoft..." while my path didn't have Microsoft

Resources