Missed Team ’24? Catch up on announcements here.

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

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

Jerome Durand March 13, 2018

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
Jerome Durand March 15, 2018

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 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.

Jerome Durand March 14, 2018

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 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.

Jerome Durand March 14, 2018

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 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.

Jerome Durand March 14, 2018

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
AUG Leaders

Atlassian Community Events