1

I'm using a shared library with jenkins 2. Meaning, I'm utilizing the ability to reuse some of the pipeline code I'm writing in various stages.

here is an example of module vars/utils.groovy

def set_virtual_env() {
    sh """
    chmod 777 virt_run_pytest.sh
    chmod 777 install_python_venv.sh

    pip install -U setuptools
    bash install_python_venv.sh
    """
}

When trying to execute it in a pipeline script, it gets failed with the following error:

groovy.lang.MissingPropertyException: No such property: set_virtual_env for class: groovy.lang.Binding

I suspect that the reason for that is because I'm not passing any variable to this function and as a result it's not instantiated correctly.

So the actual question might be, "How can I call a shared library function that does not needs arguments"?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
ForMartha
  • 107
  • 1
  • 10

1 Answers1

1

I was calling the object and not the method. meaning, I called it:

utils.set_virtual_env

Instead of

utils.set_virtual_env()
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
ForMartha
  • 107
  • 1
  • 10