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

Environment Variables Not Recognized in Agent section #180

Closed
dtrogers2 opened this issue Mar 3, 2020 · 1 comment · Fixed by #252
Closed

Environment Variables Not Recognized in Agent section #180

dtrogers2 opened this issue Mar 3, 2020 · 1 comment · Fixed by #252

Comments

@dtrogers2
Copy link

I'm using Maven to execute the groovy script that calls the JPU module.
In my setUp(), I use binding.setVariable to set the environment variable loadDirectory.
In the Jenkinsfiles that are currently being used by my company, the customWorkspace method is used with loadDirectory as the parameter inside the Agent Node section of the pipeline

Within the Stage Steps sections, the loadDirectory is able to be to be used. But when I attempt to set customWorkspace to the loadDirectory environment variable in the Agent Node section I receive the following error:
[ERROR] Failed to execute goal org.codehaus.gmavenplus:gmavenplus-plugin:1.8.1:execute (default-cli) on project test4: Error occurred while calling a method on a Groovy class from classpath. InvocationTargetException: No such property: loadDirectory for class: com.lesfurets.jenkins.unit.declarative.AgentDeclaration -> [Help 1]

I've attached the related files so you can see the code I'm using in more detail.
TestMain is originally TestMain.groovy, and testPipeline is originally testPipeline.Jenkinsfile, but those file types are not allowed to be uploaded to github.
TestMain.txt
testPipeline .txt

@stchar stchar added the bug label Mar 4, 2020
@stchar
Copy link
Contributor

stchar commented Mar 4, 2020

Yep it's a bug.
thank you.
I believe workaround would be:

def local = env.ENV_VAR
pipeline {
  agent { 
    label local
  }
//...
}

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