2

I have a jenkinsfile that defines a pipeline. In there, I declared a step which invokes the powerhell pipeline plugin and I am trying to use the jenkins environment variables as well as a build parameter with no success. See my step definition below:

stage('publish') {
      steps {
            powershell returnStatus: true, script: '$(env:WORKSPACE)\\ci\\scripts\\publish-$(BRANCH).ps1'
      }
    }

Any help/insight will be greatly appreciated.

0

1 Answer 1

1

There are two problems with your pipeline:

  1. Single quotes will not extend variables inside the string
  2. To access variables you user ${var} and not $(var)
  3. Not wrong, but you do not need to use env.WORKSPACE, just WORKSPACE is sufficient

Please give it a try, you can add the echo before your powershell command so you can see what you are trying to execute.

stage('publish') {
  steps {
        echo "${WORKSPACE}\\ci\\scripts\\publish-${BRANCH}.ps1"
        powershell returnStatus: true, script: ${WORKSPACE}\\ci\\scripts\\publish-${BRANCH}.ps1"
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.