You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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
@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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.