Details
-
Suggestion
-
Resolution: Unresolved
-
None
Description
I'm sending an email message for some pipelines using an after-script clause, and the email-notify pipe. To avoid repeating all the details of email sending, I use yaml anchors, but I'd like to customize the email message to identify the pipeline that failed. The end result is currently something like this:
definitions: .send_email_def: &send_email_on_fail after-script: - if [[ $BITBUCKET_EXIT_CODE == 0 ]]; then false; else true; fi #only continue if build actualy failed - pipe: atlassian/email-notify:0.4.3 variables: USERNAME: $SMTP_USER PASSWORD: $SMTP_PASSWORD FROM: $SMTP_USER TO: 'some-user@example.com' HOST: 'smtp.gmail.com' PORT: 587 SUBJECT: "Pipeline $BITBUCKET_DEPLOYMENT_ENVIRONMENT" pipelines: custom: pipeline1: - step: deployment: pipeline1 script: - #some commands <<: *send_email_on_fail
Whereas I define a test deployment environment named "pipeline1".
Obviously this is an abuse of the deployments feature, and even if it weren't, This type of customization belongs in the source code, not in the Bitbucket project metadata.
I was thinking of something like:
definitions: .send_email_def: &send_email_on_fail after-script: - if [[ $BITBUCKET_EXIT_CODE == 0 ]]; then false; else true; fi #only continue if build actualy failed - pipe: atlassian/email-notify:0.4.3 variables: USERNAME: $SMTP_USER PASSWORD: $SMTP_PASSWORD FROM: $SMTP_USER TO: 'some-user@example.com' HOST: 'smtp.gmail.com' PORT: 587 SUBJECT: "Pipeline $PIPELINE_NAME" pipelines: custom: pipeline1: - step: variables: PIPELINE_NAME: "pipeline1" script: - #some commands <<: *send_email_on_fail
(All this is just a concrete example, I'd like to customize yaml anchors not just for setting the pipeline name but to give parameters to build scripts as well. The key point is to to be able to set a variable per-step via bitbucket-pipelines.yml and not via deployments)