The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

plussier
Contributor
August 23, 2022

Greetings.

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

 - pipe: atlassian/trigger-pipeline:5.0.1
variables:
BITBUCKET_USERNAME: ${BBUSER}
BITBUCKET_APP_PASSWORD: ${BB_PIPELINE_APP_PASSWD}
REPOSITORY: 'my_awesome_repo'
REF_TYPE: ${REFTYPE}
REF_NAME: ${REFNAME}
CUSTOM_PIPELINE_NAME: ${CUSTOM_PIPELINE}

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:
data['target'].update({
"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.

Thanks.

--

Paul

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 26, 2022

@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
variables:
...
CUSTOM_PIPELINE_NAME: 'null'

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

Regards, Igor

DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events