Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to pass an object as a pipeline parameter #32

Open
DanielPerezJensen opened this issue Feb 7, 2024 · 2 comments
Open

Unable to pass an object as a pipeline parameter #32

DanielPerezJensen opened this issue Feb 7, 2024 · 2 comments

Comments

@DanielPerezJensen
Copy link

We want to use this scaffolder to create a form that will trigger a pipeline with some configuration options.

We have done this in the pipeline using a parameter, this parameter is an object. We want to pass the content of the filled in form as an object to this pipeline parameter.

In the readme we see:

    - title: Choose Pipeline Parameters
      description: Please select some pipeline parameters
      properties:
        pipelineParameters:
          title: Pipeline Parameters
          type: object
          properties:
            name:
              type: string
            id:
              type: number
            foo:
              type: string
***note these properties for parameters are just examples, you can use whatever key values that your pi

We thought perhaps we would be able to pass an object like above, so pipelineParameters to this parameter in the pipeline.

This led us to this solution:

# template.yaml
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: create-azure-pipeline-1
  title: Run Azure Pipeline
  description: Create Azure pipeline 3
spec:
  owner: parfuemerie-douglas
  type: service

  parameters:
    - title: Backstage Information
      required:
        - name
        - owner
      properties:
        name:
          title: Project name
          type: string
          description: Choose a unique project name.
          ui:field: EntityNamePicker
          ui:autofocus: true
        owner:
          title: Owner
          type: string
          description: Select an owner for the Backstage component.
          ui:field: OwnerPicker
          ui:options:
            allowedKinds:
              - Group
    - title: Dashboard Configuration
      required:
        - dbConfig
      properties:
        dbConfig:
          title: Dashboard Configuration
          type: object
          properties:
            version:
              title: Version
              type: string
              description: Version of the dashboard to be deployed
              default: test1
            project_name:
              title: Project Name
              type: string
              description: Squad name
              default: test2
            admin_group:
              title: Admin Group
              type: string
              description: Assignment group
              default: test3
            application_ci:
              title: Application CI
              type: string
              description: App CI
              default: test4
  steps:
    - id: runAzurePipeline
      name: Run Azure Pipeline
      action: azure:pipeline:run
      input:
        organization: <ORGANIZATION>
        pipelineId: <PIPELINEID>
        project: <PROJECT>
        pipelineParameters:
          json_object: {{ parameters.dbConfig }}
  output:
    links:
      - title: Open in catalog
        icon: catalog
        entityRef: ${{ steps.register.output.entityRef }}

However, when we try to run this template through backstage, the pipeline is not triggered. We get a screen like below:
image

The pipeline seems to insta-run and succeed, however, I know for a fact the pipeline never ran through azure devops UI.

We have tried to hard-code an object, but this also does not succeed. Some options we have tried:

  steps:
    - id: runAzurePipeline
      name: Run Azure Pipeline
      action: azure:pipeline:run
      input:
        organization: <ORGANIZATION>
        pipelineId: <PIPELINEID>
        project: <PROJECT>
        pipelineParameters:
          json_object:
           test: test1
  steps:
    - id: runAzurePipeline
      name: Run Azure Pipeline
      action: azure:pipeline:run
      input:
        organization: <ORGANIZATION>
        pipelineId: <PIPELINEID>
        project: <PROJECT>
        pipelineParameters:
          json_object:
           - test: test1
           - test: test2

We have verified that we can work with the PAT, as when we drop the json_object from pipeline_parameters the pipeline can be run through Backstage.

Any help is appreciated, since we are not getting any error message we are kind of shooting in the dark. How are we supposed to form this?

@GDivino
Copy link

GDivino commented Jun 13, 2024

Bump on this 🙏. I am facing an issue with the pipelineParameter input as well.

In my case, I do not pass in a separate object, but treet pipelineParatemeters as an object already. Any way to use this pipelineParameter input?

piplineParameters:
  key: value
  key: value

@GDivino
Copy link

GDivino commented Jun 14, 2024

I found out that pipelineParameters will only work if the parameters being passed into the azure pipeline YAML are the exact same as in the azure pipeline YAML

azure-pipelines.yml

trigger: none
parameters:
  - name: terraformBundlePath
  - name: projectId
  - name: pullRequestId

template.yml

- id: runTerraformPipeline
  name: Run terraform pipeline
  action: azure:pipeline:run
  input:
    organization: <org-here>
    pipelineId: <pipeline-id-here>
    project: <project-here>
    branch: <branch-here>
    pipelineParameters:
      terraformBundlePath: <path-here>
      projectId: <project-id-here>
      pullRequestId: <pull-request-id-here> 

For your case of passing in objects, however, I'm not sure if you can pass in an object. You would need to treat pipelineParameters as its own object and pass in key-value pairs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants