Skip to content

define random strings #1346

@Sopka

Description

@Sopka

I need a constant random string available during the execution of one task.
For example to append a suffix to a resource name.

My current workaround is to assign a dynamic variable and process the output further with a golang template:

tasks:
  add-suffix:
    vars:
      SUFFIX: 
        sh: uuidgen
    cmds:
      # Select the first part of a uuid for a short random string number:
      # Outputs e.g. e01136af instead of e01136af-30d6-4b6b-9c68-f52fcaaaf313
      - echo {{index (.SUFFIX | splitList "-") 0}}

I do this, because you cannot just export a shell variable at one command and re-use it in subsequent commands.

But this workaround is not OS independent and cumbersome.

Is there an easier way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: templatingChanges related to the templating engine.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions