Missed Team ’24? Catch up on announcements here.

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

Need help posting to bitbucket api endpoint

Aaron Bauman October 2, 2019

I'm looking at the POST method for pipelines_config/schedules, but I can't figure out how to structure my POST data.

I've tried to mimic the results from GET, but to no avail.

Can someone help me restructure the POST data correctly?

 

I've tried POSTing with all of the following, and all respond with 400 bad request:

[
'enabled' => true,
'cron_pattern' => '0 4 * * *',
'type' => 'custom',
'pattern' => 'clu'
];
[
'enabled' => true,
'cron_pattern' => '0 4 * * *',
'target' => [
'type' => 'custom',
'pattern' => 'clu'
]
];
[
'enabled' => true,
'cron_pattern' => '0 4 * * *',
'target' => [
'selector' => [
'type' => 'custom',
'pattern' => 'clu'
]
]
]
[
'enabled' => true,
'cron_pattern' => '0 4 * * *',
[
'type' => 'custom',
'pattern' => 'clu'
]
]
[
'enabled' => true,
'cron_pattern' => '0 4 * * *',
'target' => [
'type' => 'pipeline_ref_target',
'ref_type' => 'branch',
'ref_name' => 'master',
'selector' => [
'type' => 'custom',
'pattern' => 'clu'
]
]
]

 

My bitbucket-pipelines.yml defines the "clu" job thusly:

pipelines:
custom:
clu:
- step:
name: Composer Lock Update Test
script:
- echo "hello world"

 

2 answers

1 accepted

0 votes
Answer accepted
Aaron Bauman October 2, 2019

OK, I figured it out.

The final version above is nearly there, just using an invalid cron syntax.

The version that works looks like this:

[
'enabled' => true,
'cron_pattern' => '0 0 4 * * ? *',
'target' => [
'type' => 'pipeline_ref_target',
'ref_type' => 'branch',
'ref_name' => 'master',
'selector' => [
'type' => 'custom',
'pattern' => 'clu'
]
]
]

This creates a scheduled task on branch "master" to run the custom task "clu" at 4am GMT, 7 days a week.

 

If the API requires specific names for elements in its expected data structures, perhaps those should be included in the API docs!?

0 votes
Mauro Badii
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 12, 2020

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events