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

Bitbucket runner crontab not working

Noah Di Gesù December 24, 2022

Hey everyone :)

 

I would like my Bitbucket runner to run as a cron job on boot. The command provided by Bitbucket to launch the runner manually works as intended, but as soon as I try to launch it from a cron job (or a from a service), I get the following in the runner's log :

[2022-12-24 12:51:49,999] Executing build script in native script.
[2022-12-24 12:51:50,047] Script exited with exit code: 1

 

This results in the pipeline failing completely, with the following output on Bitbucket :

Screenshot 2022-12-24 at 18-45-35 noahdigesu _ smoothey-sign-up — Bitbucket.png

I am using the Linux runner on an Ubuntu 20.04.5 instance hosted on AWS.

 

Here are the contents of my crontab :

 @reboot /opt/atlassian-bitbucket-pipelines-runner/bin/start.sh --accountUuid {...} --repositoryUuid {...} --runnerUuid {...} --OAuthClientId ... --OAuthClientSecret ... --runtime linux-shell --workingDirectory /opt/atlassian-bitbucket-pipelines-runner/temp/

 (... being placeholders and /opt/atlassian-bitbucket-pipelines-runner/ being the folder where everything related to the runner is stored on my file system)

 

Here is the complete runner log :

[2022-12-24 12:51:28,676] Updating runner state to "ONLINE".
[2022-12-24 12:51:40,222] Setting runner state to executing step.
[2022-12-24 12:51:40,224] Getting step StepId{accountUuid={e10f9206-9a59-4182-ac60-0aea6bd2e042}, repositoryUuid={b72e3c08-a204-4361-930e-4d4c91ab5b9a}, pipelineUuid={346845ea-9706-4d9d-ad0c-bffb130724a8}, stepUuid={f0aeb791-db1f-4978-8bad-71b1656177db}}.
[2022-12-24 12:51:40,225] Getting oauth token for step.
[2022-12-24 12:51:40,227] Getting environment variables for step.
[2022-12-24 12:51:40,585] Getting all artifacts for step.
[2022-12-24 12:51:40,597] Getting SSH private key.
[2022-12-24 12:51:40,601] Getting known hosts.
[2022-12-24 12:51:40,797] Setting up directories.
[2022-12-24 12:51:40,801] Starting log uploader.
[2022-12-24 12:51:40,804] Setting up step timeout: PT2H
[2022-12-24 12:51:40,805] Starting websocket listening to STEP_COMPLETED events.
[2022-12-24 12:51:40,806] Checking for step completion every PT30S seconds.
[2022-12-24 12:51:40,996] Updating step progress to CLONING.
[2022-12-24 12:51:41,218] Generating clone script.
[2022-12-24 12:51:41,221] Adding log file: /opt/atlassian-bitbucket-pipelines-runner/temp/7d1b991d-4db7-51d4-a743-f670097fc201/tmp/clone5070288174227783447.log
[2022-12-24 12:51:41,221] Executing clone script.
[2022-12-24 12:51:41,804] Appending log line to main log.
[2022-12-24 12:51:49,707] Script exited with exit code: 0
[2022-12-24 12:51:49,708] Not downloading artifacts. (artifactsDownloadEnabled: true, numberOfArtifacts: 0)
[2022-12-24 12:51:49,708] No caches to download
[2022-12-24 12:51:49,709] Updating step progress to BUILDING.
[2022-12-24 12:51:49,806] Appending log line to main log.
[2022-12-24 12:51:49,992] Generating build script.
[2022-12-24 12:51:49,999] Adding log file: /opt/atlassian-bitbucket-pipelines-runner/temp/7d1b991d-4db7-51d4-a743-f670097fc201/tmp/build14160541035342645415.log
[2022-12-24 12:51:49,999] Executing build script in native script.
[2022-12-24 12:51:50,047] Script exited with exit code: 1
[2022-12-24 12:51:50,068] Not uploading caches. (numberOfCaches: 0, resultOrError: FAILED)
[2022-12-24 12:51:50,069] Not uploading artifacts. (numberOfArtifacts: 0, resultOrError: FAILED)
[2022-12-24 12:51:50,070] Updating step progress to PARSING_TEST_RESULTS.
[2022-12-24 12:51:50,283] Test report processing complete.
[2022-12-24 12:51:50,284] Updating step progress to COMPLETING_LOGS.
[2022-12-24 12:51:50,504] Shutting down log uploader.
[2022-12-24 12:51:50,505] Appending log line to main log.
[2022-12-24 12:51:50,786] Tearing down directories.
[2022-12-24 12:51:50,799] Cancelling timeout
[2022-12-24 12:51:50,800] Completing step with result Result{status=FAILED, error=None}.
[2022-12-24 12:51:51,096] Setting runner state to not executing step.
[2022-12-24 12:51:51,096] Waiting for next step.
[2022-12-24 12:51:58,677] Updating runner state to "ONLINE".
[2022-12-24 12:52:28,678] Updating runner state to "ONLINE".
[2022-12-24 12:52:58,677] Updating runner state to "ONLINE".
[2022-12-24 12:53:28,677] Updating runner state to "ONLINE".
[2022-12-24 12:53:52,348] Updating runner state to "OFFLINE".
[2022-12-24 12:53:52,566] Shutdown completed

I tried taking a look at the build log (/opt/atlassian-bitbucket-pipelines-runner/temp/7d1b991d-4db7-51d4-a743-f670097fc201/tmp/build14160541035342645415.log), but I wasn't able to because the file didn't exist.

 

I'd really appreciate a bit of help for this :)

Thank you in advance !!

1 answer

1 accepted

2 votes
Answer accepted
Curtis
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.
June 27, 2024

It appears you are looking to use crontab, to start it after a reboot of the server. Have you thought about configuring it as a service instead?

Noah Di Gesù June 28, 2024

I forgot that post existed ! I indeed made it a service, and it's working completely fine now :)

Thanks!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events