I'm just getting started with Pipelines, and am trying to set one up that runs when commits are merged into our develop branch (the step/script stuff is already working when it's part of the default block; I just want to target specifically develop.)
I'm editing my bitbucket-pipelines.yml file in the online editor, and am getting a warning dot with error message when I use this config:
# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.1.1
pipelines:
branches:
develop:
- step:
name: Transition Jira ticket to done
script:
- pipe: atlassian/jira-transition:0.1.4
variables:
JIRA_BASE_URL: $JIRA_BASE_URL
JIRA_USER_EMAIL: $JIRA_USER_EMAIL
JIRA_API_TOKEN: $JIRA_API_TOKEN
ISSUE: $BITBUCKET_BRANCH
TRANSITION: "Done"
The error is occurring on the "branches" and "develop" lines; the branches error says "branches requires pattern to target specific branches", and the develop error says "Unexpected property develop".
Where am I going wrong here?
UPDATE: I did get the branch pipeline to save, using this code:
pipelines:
default:
- step:
script:
- echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."
branches:
develop:
- step:
script:
- pipe: atlassian/jira-transition:0.1.4
variables:
JIRA_BASE_URL: $JIRA_BASE_URL
JIRA_USER_EMAIL: $JIRA_USER_EMAIL
JIRA_API_TOKEN: $JIRA_API_TOKEN
ISSUE: $BITBUCKET_BRANCH
TRANSITION: "Done"
But now when I merge a commit to develop, the pipeline fails with this error:String "develop" does not contain issueKeys
Cannot find issue key
I'm glad that you could already fix the first part of the issue =]
Now the problem is on understanding how the PIPE jira-transitions works. According to what is described in the link before, the ISSUE attribute should receive a Jira issue key but it is receiving the name of the branch which will be always develop.
I guess the example you see for jira-transitions (where you use the variable $BITBUCKET_BRANCH) was designed to be used in the default section to capture branches created with a Jira key name.
If, for example, you are trying to transition an issue based on issue keys present in your commit messages, you will need to parse this data using a different command and create a new variable where the affected Jira issue is present. If this is your case, you would need something like:
JIRA_ISSUE=$(git log --pretty=format:%s -1 $BITBUCKET_COMMIT | grep -E -o '\<[A-Z][A-Z0-9]+\-[0-9]+\>' | head -1)
⚠️ Please keep in mind that this is just an example. You will need to adjust it to match your needs.
I hope that helps.
Thanks, @Daniel Santos
Just to make sure I understand, I can keep the develop branch and the predefined pipe; I just need to find another way to populate the ISSUE variable that's currently using $BITBUCKET_BRANCH?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, that is right! =]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OK. Again, keeping in mind this is my first-ever pipeline, I commented out the pipe and just tried to echo out the value of what the regex should return, but it's giving me a command not found error on "git". Do I need to somehow make sure that git is installed on the docker image?
(The regex does match what I'm looking for when I test it here against some of our ticket number formats (any number of letters, a dash, any number of numbers).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, you need to make sure git is installed so the command can succeed. You will need it to get the commit message.
I tested this command using the default docker machine atlassian provides when you don't specify a specific image.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.