1 build compatible for Windows and Linux agents

Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 21, 2016

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

0 votes
Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 21, 2016

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

 

0 votes
John Betz April 21, 2016

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

Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 21, 2016

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.

 

Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 21, 2016

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

John Betz April 21, 2016

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.

John Betz April 21, 2016

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.

 

Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 21, 2016

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

John Betz April 21, 2016

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events