Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to call pipeline through trigger-pipeline pipe

François Collins May 30, 2022

I already have pipeline triggers between repositories working without any issues. 

Now, I have a new custom pipeline in a third repo (all are in the same workspace). In my existing repo where I already have a pipeline trigger for a custom pipeline, when I call the new pipeline, I keep getting "Account, repository or branch doesn't exist."

This new pipeline works perfectly when I run it manually from its repo. I copy / pasted the repo name, branch and pipeline names. All repos in the workspace use the same SSH key.

In the following, &chart step works but &deploy-cdk doesn't. What am I missing? They are pretty similar except for the number of variables. I tried adding ACCOUNT variable with workspace name, removing BRANCH_NAME (target repo only has "main" branch), nothing works.

 

- step: &chart # Update Helm chart in non production flow. ** Assumes a chart is present

        name: Update helm chart value with the build number

        script:

          - cat tag.sh

          - source tag.sh

          - pipe: atlassian/trigger-pipeline:5.0.0

            variables:

              BITBUCKET_USERNAME: '${BB_PIPE_USER}'

              BITBUCKET_APP_PASSWORD: '${BB_PIPE_PW}'

              REPOSITORY: 'microservices-charts'

              BRANCH_NAME: 'master'

              CUSTOM_PIPELINE_NAME: 'update-k8s-values'

              PIPELINE_VARIABLES: >

                  [{

                    "key": "REPO_SLUG",

                    "value": "${BITBUCKET_REPO_SLUG}"

                  },

                  {

                    "key": "IMAGE_TAG",

                    "value": "${IMAGE_TAG}"

                  },

                  {

                    "key": "VACV_ENV",

                    "value": "dev"

                  }]

              WAIT: 'true'

    - step: &deploy-cdk

        name: deploy CDK

        script:

          - echo "Commit hash is ${BITBUCKET_COMMIT}"

          - pipe: atlassian/trigger-pipeline:5.0.0

            variables:

              BITBUCKET_USERNAME: '${BB_PIPE_USER}'

              BITBUCKET_APP_PASSWORD: '${BB_PIPE_PW}'

              REPOSITORY: 'packages-spa-deployment'

              BRANCH_NAME: 'main'

              CUSTOM_PIPELINE_NAME: 'dev-build'

              PIPELINE_VARIABLES: >

                  [{

                    "key": "BUILD_HASH",

                    "value": "${BITBUCKET_COMMIT}"

                  }]

              WAIT: 'true'

              DEBUG: 'true'

Custom pipe being called:
pipelines:

  custom:

    dev-build:

    - variables:

        - name: BUILD_HASH

    - step:

        name: log commit hash

        script:

          - echo "Updating dev bucket with latest commit $BUILD_HASH"

    - step: *build-cdk

    - step: *cdk-deploy-np
         

5 answers

1 accepted

0 votes
Answer accepted
lissyaka June 10, 2022

@François Collinshi. The problem is that you use wrong configuration in bitbucket-pipeline.yml.
In this version of pipe 5.0.0
It should be:

REF_TYPE: 'branch'
REF_NAME: 'main'

instead of
BRANCH_NAME: 'main'

according to documentation.

'REF_NAME': {'type': 'string', 'required': False, 'default': 'master'},
'REF_TYPE': {'allowed': ['branch', 'tag'], 'default': 'branch', 'type': 'string'}

so in your case pipe search for a master branch instead of main.

Hope it helps.

Cheers
François Collins June 10, 2022

Congratulations! You nailed it.

It didn't happen on any other pipe trigger when I upgraded the version, it seems to work anyway with the previous syntax. However, since my colleague happened to name the main (and only) branch "main" in this specific scenario, it caused confusion.

The other pipe triggers still work because in the other repos we reference, the main branch is called "master". Subtle.

Like lissyaka likes this
0 votes
lissyaka June 8, 2022

@François Collins  hi. Can you try to add ACCOUNT to pipe according to example into your &deploy-cdk step:

Basic example. This pipe will trigger the branch pipeline for master in your-awesome-repo that is owned by the teams-in-space Bitbucket account.

script:
  - pipe: atlassian/trigger-pipeline:5.0.0
    variables:
      BITBUCKET_USERNAME: $BITBUCKET_USERNAME
      BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
      REPOSITORY: 'your-awesome-repo'
      ACCOUNT: 'teams-in-space'

The default is $BITBUCKET_REPO_OWNER, but maybe you have different account in that workspace.

Cheers

François Collins June 8, 2022

I already tried that and it didn't make any difference. Besides, we only have one workspace, and Mark C stated that it's only required if you're referencing a pipeline in a different workspace.

0 votes
lissyaka June 3, 2022

@François Collinshi. I see that you have branch master in microservices-charts, and branch main in packages-spa-deployment from your configuration yml file. Is this correct? Maybe the problem is you need to trigger master branch in packages-spa-deployment?

Cheers

 

François Collins June 3, 2022

packages-spa-deployment only has one branch "main".

0 votes
François Collins June 1, 2022

Hi @Mark C, can you state on whether a pipeline in repo 1 can only be called remotely in repo 2 if pipeline 2 SSH is the same user that created repo 1?

If not, what would explain that pipeline 2 SSH (which is admin user) cannot access the remote pipeline in repo 1 if everything else is the same?

All repos in workspace are using the same admin user SSH in pipeline settings in order to be able to clone other repos.

To restate:

Repo 1 -> manual run of custom pipeline -> works

Repo 2 -> pipe -> custom pipeline in repo 3 -> works

Repo 2 -> pipe -> custom pipeline in repo 1 -> does not work

Create repo 4 with exact same setup as repo 1 but creator is admin, copy files from repo1, test that custom pipeline runs within its repo

Repo 2 -> pipe -> pipeline in repo 4 -> works after changing just the repo name in pipe variables.

Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 2, 2022

Hi @François Collins

Using the Pipes script (atlassian/trigger-pipeline) shouldn't be dependent on any SSH key since it's authenticating through HTTPS via username and app password.

For us to continue to investigate the issue further, I've gone ahead and raised a support ticket for this.

You should receive an email notification about it and let's continue our investigation there.

Regards,
Mark C

0 votes
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 1, 2022

Hi @François Collins

Welcome to the community.

If the repository is under the same workspace where you've run the Pipes script (atlassian/trigger-pipeline:5.0.0), it's fine not to include the variable "ACCOUNT" but if it's from another workspace, you'll have to include it

For the repository (packages-spa-deployment), would you be able to confirm if Pipelines is enabled there and if the file "bitbucket-pipelines.yml" exists in the main branch?

Thanks and let me know how it goes.

Regards,
Mark C

François Collins June 1, 2022

They are all in the same workspace, packages-spa-deployment has the yaml file, it only has main branch, and as I mentioned it works when I run it from within the repo. 

I couldn't figure out what was different between packages-spa-deployment and the other repo from where I can successfully call another pipeline (SSH keys, access, variables, branch permissions, etc), they seemed identical to me. The surrogate user in the pipeline SSH is supposed to have administrator access to all repos.

So as a last resort, I created a new repo alltogether while logged on as the same user as the SSH, copied the files from packages-spa-deployment into this new repo, redid the same setup as the original, and now everything works. I can call the pipeline in the copied repo.

It looks like the target repo must have been created by the same user that calls it remotely. This is annoying, because I need to call several pipe triggers from the same repo. Fortunately at the moment they were all created by the same admin user, but it might not always be the case.

Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 2, 2022

Hi @François Collins

Thanks for that info.
Is there a chance the repository (packages-spa-deployment) is a forked repository?

Regards,
Mark C

François Collins June 2, 2022

No it isn't.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events