Skip to content

Using ENV Variables in Target Command #145

Open

Description

@agosto-lorinronken

Hello,

I am having trouble identifying the correct syntax to apply an environment variable to my salt pipeline in order to feed that to the Salt command. Essentially, we have an upstream pipeline that sets up a server and a downstream pipeline that runs Salt on that newly configured server. I am feeding the server name as a Environment variable into the downstream job but having trouble finding how to reference it in salt. Here is the command I currently am trying:

stage('Apply Salt Rev Configuration') {
       steps {
         salt(authtype: 'pam', clientInterface: local(arguments: 'My APP 1', function: 'grains.append', target: '{{CA_HOSTNAME}}', targettype: 'glob'), credentialsId: 'my-salt-master', saveFile: true, servername: 'myservername.com:8000')
         script {
          env.WORKSPACE = pwd()
          def output = readFile "${env.WORKSPACE}/saltOutput.json"
          echo output
        }
       }
    }

I have tired to also use {{env.CA_HOSTNAME}} and "{{CA_HOSTNAME}}" to no avail. I have tested the above command by manually providing the server name versus using the CA_HOSTNAME variable and confirmed that the salt config applied correctly.

Is this supported by chance and if so what am I missing?

Thank you for your help!!

Activity

  1. yukpun commented on Jul 29, 2021

    @yukpun

    Try to use just ${WORKSPACE} or ${CA_HOSTNAME}
    One more variant it could be - ${params.WORKSPACE}
    Maybe it could help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions