metadata:
  name: isChangeInDevelopment
  description: This step checks if a certain change is in status 'in development'
  longDescription: |
    This step checks if a certain change is in status 'in development'

spec:
  inputs:
    secrets:
      - name: credentialsId
        description: Jenkins 'Username with password' credentials ID containing user and password to authenticate against the ABAP backend
        type: jenkins
        aliases:
          - name: changeManagement/credentialsId
    params:
      - name: endpoint
        type: string
        mandatory: true
        description: "The service endpoint"
        aliases:
          - name: changeManagement/endpoint
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
          - GENERAL
      - name: username
        type: string
        mandatory: true
        description: "Service user to authenticate against the ABAP backend"
        secret: true
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
          - GENERAL
        resourceRef:
          - name: credentialsId
            type: secret
            param: username
      - name: password
        type: string
        mandatory: true
        description: "Service user password to authenticate against the ABAP backend"
        secret: true
        scope:
          - PARAMETERS
        resourceRef:
          - name: credentialsId
            type: secret
            param: password
      - name: changeDocumentId
        resourceRef:
          - name: commonPipelineEnvironment
            param: custom/changeDocumentId
        type: string
        mandatory: true
        description: "ID of the change document to be checked for the status"
        scope:
          - PARAMETERS
      - name: failIfStatusIsNotInDevelopment
        type: bool
        default: true
        description: "lets the build fail in case the change is not in status 'in developent'. Otherwise a warning is emitted to the log"
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
      - name: cmClientOpts
        type: "[]string"
        description: "additional options passed to cm client, e.g. for troubleshooting"
        scope:
          - PARAMETERS
          - STAGES
          - STEPS
        aliases:
          - name: clientOpts
          - name: changeManagement/clientOpts
  outputs:
    resources:
      - name: commonPipelineEnvironment
        type: piperEnvironment
        params:
          - name: custom/isChangeInDevelopment
            type: bool
  containers:
    - name: cmclient
      image: ppiper/cm-client:3.0.0.0
