Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Task returning -1 when running on a remote agent running as a Windows service

I have a Bamboo remote agent running a Job that basically:

-Checkout a PowerShell script in a sub-directory

- and Run the PowerShell script (This script,among others, build the code from the main directory)

This work perfectly fine when I run the remote agent manually in a terminal, but when the remote agent run as a service (installntservice), the task running the script is failing returning -1.

 

As I had problem with Git right to checkout the script, I have change the "bamboo-remote-agent" service "Log On As" option from " Local Service" to the windows account username. It solve the Git checkout error I had but not the script failing error.

 

I have added in /conf/wrapper.conf the following:

wrapper.java.additional.3=-Djava.io.tmpdir="C:\bamboo_agent\temp"

(On Windows, when the Bamboo remote agent is installed as a service under the Local System user account. The temporary folder created by the agent isn't accessible by any other application. To allow enable to that folder, configure the agent to use a commonly accessible temporary folder by defining a new Java property in the service wrapper.)

but I don't know how I can checkout my script into that temp directory and then run it from a Bamboo task.

Any help would be appreciated.

 

Thanks,

2 answers

1 accepted

0 votes
Answer accepted

https://confluence.atlassian.com/bamkb/command-is-not-recognized-as-an-internal-or-external-command-744720688.html

 

When Running Bamboo as a Windows service as the local user, make sure you have no User variable "PATH" in Environment Variables.

0 votes
Omar Herrera Community Leader Mar 13, 2018

Hi @Jerome Durand I had been working with windows agents for a while and I never need access to temp folder on the agent.

All the code and the script must be on the working directory for example

agent-working-directory/   
        script-folder/ 
        src/
files.*

 All files that you need on the agent for made the build need store in this structure.

In my case the call to powershell script is lik this.

Capture.JPG

 

Cheers.

Thank you @Omar Herrera for your reply.

Ok I won't bother with temp file then, thanks.

This is pretty much what I am doing.

Basically I have 2 git repositories that are checkout in the first task of the job (Source Code Checkout).

The first repo contain the source code and some files, and the second one some scripts to be run:

So I get the same structure than your example before running my script:

agent-working-directory/

       script-folder/

       src/

       files.*

   

I then call my Init script like this:BambooScript.PNG

This work perfectly fine when I run the agent manually in a terminal but when it is run as a service then the script return -1 directly, the first line of the script isn't even run. I know that the script work as again it work fine when the agent  is ran manually.

The only thing that I can think is that my init script interfere with tools and other scripts that are outside of the working directory. But why would that work manually?!

 

Thanks for your help.

Jerome

Omar Herrera Community Leader Mar 14, 2018

Hi @Jerome Durand can you try configured the service run with the same windows account that you are using in command line. 

I'm agree with you about the interfere but with the right privilegies you will not problems.

Cheers.

Hi @Omar Herrera,

 

As I said in my first post, I already did that. It solved another problem I had with Git but not the script error:

 

"As I had problem with Git right to checkout the script, I have change the "bamboo-remote-agent" service "Log On As" option from " Local Service" to the windows account username."

Omar Herrera Community Leader Mar 14, 2018

Sorry @Jerome Durand my apologize for not being able to help you, my configuration is the same to you.

I'm still thinking that a issue with permission.

Cheers.

Thanks @Omar Herrera for your help, after spending some time debugging, I found out that normal Shell script were working fine, and that powershell itself wasn't recognized as an internal or external command even though it was in my System environment variable and recognized when the Bamboo remote was run manually.

And I found the solution on this page:

https://confluence.atlassian.com/bamkb/command-is-not-recognized-as-an-internal-or-external-command-744720688.html

 

When Running Bamboo as a Windows service as the local user, make sure you have no User variable "PATH" in Environment Variables.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

673 views 1 6
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you