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

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.

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,813 views 0 6
Read article

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