Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

trigger-pipeline-5.0.1 fails on variables containing the empty string


It seems that when calling trigger-pipeline-5.0.1 like this:

 - pipe: atlassian/trigger-pipeline:5.0.1
REPOSITORY: 'my_awesome_repo'

that the pipe will fail if ${CUSTOM_PIPELINE} is an empty value.  Looking at the code in the pipeline the problem seems to be with this section:

if custom_pipeline is not None:
"selector": {
"type": 'custom',
"pattern": custom_pipeline

 The issue is that testing for "is not None" merely checks to make sure the variable 'custom_pipeline' does not exist. It does not take into account the fact that the variable may exist but not contain a useful value

There are lots of reasons for setting the variable despite not actually wanting it to hold a useful value. The major reason in bitbucket pipelines would be to have a trigger which can be used in various ways but executed differently. 


In my case, I want to REFNAME to be one of [ develop, release, master ], but CUSTOM_PIPELINE to be empty when on one of the above branches in order to trigger the corresponding branch in the triggered repo. However, on a feature branch, I want REFNAME to be 'develop' all the time, and trigger a custom pipeline in the remote repository with the name passed in "${CUSTOM_PIPELINE}".


The way the pipeline is written now, I can't set "${CUSTOM_PIPELINE}" to an empty value. The mere presence of the "CUSTOM_PIPELINE_NAME" automatically the triggers the "if custom_pipeline is not None:" code. Which is not what should happen on an empty string value.


It would be better written as:

if (not custom_pipeline and not custom_pipeline.isspace() ):

Or similar.




1 answer

0 votes

@plussier  hi. Thanks for your feedback.

Try this to cover your case (The way the pipeline is written now, I can't set "${CUSTOM_PIPELINE}" to an empty value.)

 - pipe: atlassian/trigger-pipeline:5.0.1

 This will exactly set CUSTOM_PIPELINE_NAME to an empty value (None in python)

Regards, Igor

Suggest an answer

Log in or Sign up to answer
Site Admin
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

3,462 views 3 10
Read article

Atlassian Community Events