1 build compatible for Windows and Linux agents

I have a build plan that should run on any agent (Linux or Windows)

 

In the plan I have a Script Task which calls a script file on the server. For this I have to provide the filename of my script.

Script file is called gradlew for Linux and gradlew.bat for Windows. Both files are present in the working directory when checking out the git repo.

  • Linux: works fine
  • Windows: com.atlassian.utils.process.ProcessNotStartedException: ./gradlew could not be started

After some troubleshooting I replaced "gradlew" by "gradlew.bat" in the script task.
This worked! But not for linux of course

I thought using an inline script could solve the problem but then I would have to call /bin/sh gradlew on Linux which won't work on Windows again.

Any ideas how to handle this?

2 answers

Linux does not care about extension names, in the sense that they have magic meanings.  Rename gradlew to gradlew.bat on linux

You mean the file itself in the working directory?

Can't really do that as gradlew.bat already exists for Windows. Both files are being checked out of GIT on each OS.

 

yes, but then again. The sylmlink has to be created at the beginning of each build because we're starting from a clean directory. The ln command would work on Linux but throw an error on Windows

http://stackoverflow.com/questions/17510688/single-script-to-run-in-both-windows-batch-and-linux-bash

This might help, if the script using this trick is used the appropriate script.

I removed the symlink comment when I thought the same thing you did.  But, perhaps if the symlink was created by a different user (not as part of the build) and bamboo was not given permission to delete (chmod 755) it might work.  Sort of depends on how bamboo cleans directory.

 

ok thanks for clarifying and your suggestion.

I will ask the developers using the build plan if that stackoverflow idea helps them out. I had another idea myself that might be easier but not ideal. Adding it in a minute

Bamboo has settings to clean or  not clean directories.  This may cause problems.  If so, adding a task to the script to clean directories instead of bamboo before the loading of the repository data might work.

0 votes

What might work is adding a capability to each agent. For Windows agents the value would be .bat, for Linux agents it will be empty. Let's call it file.extension

In the script task we can set gradlew${bamboo.capabilities.file.extension}}} as file name

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Statuspage

How do your teams prepare for really high (planned) traffic days like Cyber Monday?

Hi there! Shannon from Statuspage here.  👋  With Cyber Monday quickly approaching, we're looking to hear from Atlassian customers – specifically from teams who touch incident response li...

58 views 0 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you