is it possible to schedule a 1-time pipeline run?
Asked by Cyrus Afshari:

I have a pipeline set up already, but I'd like to schedule it to run once, in the future at a specific time. This way i won't have to be around to trigger it at the moment I want it to run. Is this possible?


Answers:
author: Syahrul
body: G'day, [@Cyrus Afshari](/t5/user/viewprofilepage/user-id/5497331)

You can check our guide below on how to create schedules for your pipeline:

[Create a schedule for your pipeline](https://support.atlassian.com/bitbucket-cloud/docs/pipeline-triggers/#Create-a-schedule-for-your-pipeline)

However, if you need it to be on a specific day or time you'll have to use our API endpoint to create a custom schedule.

[Pipeline - Create schedule endpoint](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#api-repositories-workspace-repo-slug-pipelines-config-schedules-post)

For example:  

```
curl -u <username>:<password> -X POST --url https://api.bitbucket.org/2.0/repositories/<workspaceID>/<repoSlug>/pipelines_config/schedules/  --header 'Content-Type: application/json' --data '{"cron_pattern": "0 0/1 * 1/1 * ? *","enabled": "true",   "type": "pipeline_schedule",   "target": {    "ref_type": "branch",    "ref_name": "<branch_name>",    "type": "pipeline_ref_target",    "selector": {     "type": "branches",     "pattern" : "testpattern"    }   }}'
```

* **cron_pattern**is the specific date/time you wish the build to be triggered. You can use online generator to get te specific date/time
* **ref_name** is the branch name
* **type** is the type of pipeline definition you are selecting. For example, a custom definition, a branch trigger definition, or a pull request trigger definition.
* **pattern** is the branch pattern we define in yaml file. For instance, feature/\*\*  
  ![](https://getsupport.atlassian.com/images/icons/emoticons/information.png) Note: **ref_name** is equivalent to the branch you select in the UI while triggering a build  
  Reference: <https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#api-repositories-workspace-repo-slug-pipelines-config-schedules-post>

Regards,  
Syahrul

comments: author: Cyrus Afshari
body: I have pipeline variables that I can set via the UI (and have default and allowed-values for) when I'm manually triggering, so how would I set those variable values via the API for a scheduled run?


author: Cyrus Afshari
body: I am looking for this feature but it seems now 4 years since it being requested, it still hasn't been implemented: <https://jira.atlassian.com/browse/BCLOUD-20328>


author: Syahrul
body: Hi [@Cyrus Afshari](/t5/user/viewprofilepage/user-id/5497331)

I got it. I will inquire about the feature request, so please watch it for any future updates. Unfortunately, there are currently no workarounds to set variables for a scheduled run unless the variables are manually input or exist in the variables list.

Regards,  
Syahrul


author: Cyrus Afshari
body: Thanks. What do you mean by "manually input" and "exist in the variables list?" In my pipeline file, for the custom job I do have them listed as variables with default values and a list of [*allowed-values*](https://bitbucket.org/blog/predefine-values-of-custom-pipeline-variables)


author: Syahrul
body: Hey [@Cyrus Afshari](/t5/user/viewprofilepage/user-id/5497331)

What I mean by manual input is manually triggering the pipeline and inputting the variable:

<https://support.atlassian.com/bitbucket-cloud/docs/pipeline-triggers/#Run-a-pipeline-manually-from-the-Commits-view>

As for existing in the variables, it is to have the variables stored in the repository or your workspace level and call it in your YAML build.

Regards,  
Syahrul


Tags: bitbucket-cloud

cloud