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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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
4,553,092
Community Members
 
Community Events
184
Community Groups

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

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

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Aug 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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events