How can i set result of pipelines script execution? (Success / Fail)

Hi, All

I'm using bitbucket pipelines for run unittests. If any tests failed, i need a red (not green) mark for this run at pipelines page. Can i implement this?

 

my bitbucket-pipelines.yml:

image: vb64/gae.python.sdk
pipelines:
default:
  - step:
script:
  - cd tests
  - python tests.py $APP_ENGINE_DIR

 

end of log:

FAIL: test_order (www_tests.telegram_test.test_input.TestCaseInput)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/atlassian/bitbucketci/agent/build/tests/www_tests/telegram_test/test_input.py", line 101, in test_order
self.assertIn("command not implemented yet...", data['text'])
AssertionError: 'command not implemented yet...' not found in u'Hi, Vitaly !\n\n/order command not implemented yet.'
----------------------------------------------------------------------
Ran 85 tests in 11.279s
FAILED (failures=1)

1 answer

3 votes

Hi Vitaly,

Pipelines uses the exit status of your script to determine whether the pipeline has succeeded or failed. If your pipeline result is a success that means that all the commands in your script returned a zero exit status. To get the result you're looking for you need to make sure that your test runner (tests.py in your script) returns a non-zero exit code when there are test failures.

Thanks, Steven.

So, script execution is terminating at first command with nonzero exit code?

Yes, that's correct.

 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

29,159 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you