Looking for a bit of guidance on a tricky freestyle project

I’ve been tasked with building a freestyle project to build some firmware for a specialist device, the problem is the compiler tool used to compile the source files requires every file in the build to explicitly specified.

To give an example:

"thecompiler.exe file1.src file2.src file3.src"

What I’d like to be able to do is just have Jenkins gather a list of the “*.src” files in the current workspace folder into an environment variable, and then pass that variable to the compiler.

So for example

set filesstring = "file1.src file2.src file3.src" // from a freestyle build step *.src
"thecompiler ${filestring} /a /b /d"

That way when the devs add a new file to the build, I don’t need to edit the build configuration.

Please note, I have to do this using “freestyle” as the dev teams that will be responsible for looking after it once I finish my task, do not want to learn groovy, nor will their department head let them (I know, I know before anyone goes eh?? … those of you who have experienced office politics will know …)

Basically, they are ONLY allowed to use Jenkins if everything can be kept as nice and clicky web UI boxy ticky things as possible.

I do have some ideas on how to implement it in other ways, but I wanted to know if their might be a Jenkins native way to do it before I set myself down that path. The team are all .NET devs, so I’m thinking about building some external C# command line tools to do what I need, and just calling them from the build script.

Target system is a Windows 2016 Server Instance running Jenkins under open-jdk, the compiler is an EXE only, and will only run on windows (I’ve tried under wine… boom!)

In the same project I need to build and manipulate a Json file from a freestyle build step too, but that’s for another question once I solve this one :slight_smile:

why not thecompiler *.src /a /b /d?

Write your logic inside a batch script, powershell script, vb script, or whatever else, and have jenkins call that. Its easier to test and maintain outside of jenkins.

That’s what I feared the answer was going to be :slight_smile:

thecompiler ${filestring} /a /b /d

is there a freestyle way (or plugin) to get the file names into “${filestring}” that was basically what I was mostly looking for an answer for.

as for “why not *.src”, thats the way the compiler they use has been written, and trust me that’s not the limit of it’s faults!

This is a compiler that you can type

thecompiler im_a_non_existing_file.src /a /b /c

and it will tell you “successfull” and produce an output, so that should give you some idea as to the quality of the code.

Unfortunately, it’s the ONLY compiler of it’s kind for the custom code they compile, and they fell out with the previous vendor who wrote the compiler and the language for them, so no hope of getting the source code for it either.

My goto option if this wasn’t possible is to basically, code some tools up in C# (The language the dev team knows well) and just call those tools from jenkins, looks like thats the route I’ll have to take.

Thanks anyway :slight_smile:

Can you do this in msbuild? It has a way to expand a file list into an actual list of existing files which seems like it could meet your needs and it should be somewhat familiar to the devs since they are a .Net shop.

@slide_o_mix I don’t think so as the files are not .NET compile-able, the actual source files to be compiled are a weird “c like” format, but not actually regular C.

That said the idea of doing things that way does intrigue me, I’ll have a sleep on that idea and have a play in the morning.

Thanks, I’ll give that one some thought.

msbuild doesn’t have to be used for just .Net projects. You can call an exe and pass the file list that has been generated.

You could specify the set of files using the and then use the task and pass the list generated from the Include.

Yea, it’s late :slight_smile: I had to think about that for a little while, been a long time since I used “raw MSBuild” (I have sayed ibrahim’s book on it somewhere) , I’ve gotten so used to VS and the JetBrains tooling doing “stuff” for me, it’s been a while since I’ve used it.

As I say, the idea intruiges me, I’ll have a play in the morning.

1 Like

So quick update, I solved the problem with a bit of creative batch scripting, and a couple of custom .NET command line tools, I actually ended up writing a wrapper for the compiler that takes the exact same flags as the compiler itself, but also accepts a wildcard for file selection.

I did have a play with MSBuild and while I was happy with it, the dev team I’m supporting apparenty where not to quote: “We ONLY use Visual Studio with a mouse”, so that idea didn’t take too well.

They actually wanted me to do the .NET tools I created as windows forms GUI tools so they could see the output when they where running, it took me a bit of convincing that command lines cannot put desktop GUI’s into a web page…

Yes, the team I’m supporting really are that bad! but thier boss worships them, and thinks there the best ever… (Sigh)

Anyway thank’s those of you who answered my question, I’m gonna consider it closed now. :slight_smile: