Parfuemerie-Douglas / scaffolder-backend-module-azure-repositories

A collection of Backstage scaffolder backend modules for Azure repositories.
https://www.npmjs.com/package/@parfuemerie-douglas/scaffolder-backend-module-azure-repositories
Apache License 2.0
10 stars 25 forks source link

pullRequestAzureRepoAction does not work #10

Closed JetteBke closed 1 year ago

JetteBke commented 1 year ago

Hello everybody, I am trying to implement the pullRequestAzureRepoAction in my template but it doesn't work for me. I am using "@parfuemerie-douglas/scaffolder-backend-module-azure-repositories": "^0.2.2" and implemented the code as described in the docs adding in the scaffolder.ts with the imports and

  const actions = [
    ...builtInActions,
    cloneAzureRepoAction({ integrations }),
    pushAzureRepoAction({ integrations, config: env.config }),
    pullRequestAzureRepoAction({ integrations }),
  ];

Now, If I start the app I receive

[1] Backend failed to start up TypeError: (0 , _parfuemerie_douglas_scaffolder_backend_module_azure_repositories__WEBPACK_IMPORTED_MODULE_2__.pullRequestAzureRepoAction) is not a function

If I change the version to 0.2.4-next.2, the app starts normally. In my template yaml, I added

    - id: pullRequestAzureRepo
      name: Create a Pull Request
      action: azure:repo:pr
      input:
        sourceBranch: <BRANCH>
        targetBranch: main
        repoId: <REPO>
        title: 'Create ${{ parameters.name }}'
        project: <PROJECT>

The previous steps of clone and push work fine and the last step fails with

[1]2023-07-18T13:05:43.247Z Beginning step Create a Pull Request 
[2]2023-07-18T13:05:43.685Z TypeError: Cannot read properties of null (reading 'value')
[3]   at /backstage/node_modules/azure-devops-node-api/VsoClient.js:124:52
[4]   at runMicrotasks (<anonymous>)
[5]   at processTicksAndRejections (node:internal/process/task_queues:96:5)

I have read the docs multiple times and tried changing to use other repos or branches but I end up here again. Could you have a look and maybe help me out? Happy to submit more info if necessary.

Other dependency versions

    "@backstage/backend-common": "^0.19.0",
    "@backstage/backend-tasks": "^0.5.3",
    "@backstage/catalog-client": "^1.4.2",
    "@backstage/catalog-model": "^1.4.0",
    "@backstage/config": "^1.0.8",
    "@backstage/integration": "^1.5.0",
    "@backstage/plugin-adr-backend": "^0.3.4",
    "@backstage/plugin-app-backend": "^0.3.46",
    "@backstage/plugin-auth-backend": "^0.18.4",
    "@backstage/plugin-auth-node": "^0.2.15",
    "@backstage/plugin-azure-devops-backend": "^0.3.25",
    "@backstage/plugin-catalog-backend": "^1.10.0",
    "@backstage/plugin-catalog-backend-module-azure": "^0.1.17",
    "@backstage/plugin-permission-common": "^0.7.6",
    "@backstage/plugin-permission-node": "^0.7.9",
    "@backstage/plugin-proxy-backend": "^0.2.40",
    "@backstage/plugin-scaffolder-backend": "^1.15.0",
    "@backstage/plugin-search-backend": "^1.3.2",
    "@backstage/plugin-search-backend-module-pg": "^0.5.7",
    "@backstage/plugin-search-backend-node": "^1.2.2",
    "@backstage/plugin-techdocs-backend": "^1.6.3",
    "@parfuemerie-douglas/scaffolder-backend-module-azure-repositories": "^0.2.4-next.2",
    "app": "link:packages/app",
    "dockerode": "^3.3.5",
    "express": "^4.17.1",
    "express-promise-router": "^4.1.0",
    "pg": "^8.11.1",
    "winston": "^3.10.0"
fosterm-mw commented 1 year ago

Hey @JetteBke I've just tested this with 0.2.4-next.2 and I was able to successfully create a PR to the repository. Here is what my yaml block looked like:

- id: pullRequestAzureRepo
      name: Create PR to GitOps Repo
      action: azure:repo:pr
      input:
        organization: <ORGANIZATION>
        sourceBranch: "<BRANCH>"
        targetBranch: "main"
        repoId: <REPO>
        title: debug
        project: <PROJECT>
        supportsIterations: false

It's unfortunate there isn't better logging, have you tried setting the organization?

JetteBke commented 1 year ago

Hey @fosterm-mw, setting the organization fixed it for me, thank you! That should be added to the documentation. Thank you so much, awesome!