Re: Jenkinsfile Accessing variables from shared libraries

2020-12-20 Thread Yannick Lacaute
Hi, First, if you want "echo", you could just use echo without the sh : echo "hello" Then, if you want to print a variable in the echo, use this syntax : echo "hello ${myGroovyVariable}" You must use double quote, if you use single quote the echo will print *exactly* what you have written

Re: Jenkinsfile Accessing variables from shared libraries

2020-12-19 Thread Kernel Panic
Hello Is there a way to access those variables from as sh command from the script section? for example this works: script { echo GlobalVariables.MyVariable } but the same with sh does not, that just echos GlobalVariables.MyVariable and not the variab

Re: Jenkinsfile Accessing variables from shared libraries

2020-12-19 Thread Kernel Panic
Hello Defining a global class worked for me, at least did what I wanted to do, Thanks you very much for your time and support Regards El jueves, 17 de diciembre de 2020 a las 5:45:11 UTC-3, venh...@gmail.com escribió: > In my case, I do the following. I have a GlobalVars.groovy file with below

Re: Jenkinsfile Accessing variables from shared libraries

2020-12-17 Thread Yannick Lacaute
Hi, I think you should not use global variables at all : only global functions. Trust me : you don't need global variables :) To use global functions : # /vars/myGlobFunc.groovy def call() { // } // This way you can call you function directly in "steps" if you are in declarative pipeline,

Re: Jenkinsfile Accessing variables from shared libraries

2020-12-17 Thread Ven H
In my case, I do the following. I have a GlobalVars.groovy file with below content. #!/usr/bin/env groovypackage com..;public class GlobalVars { static String myVar = ""} Then in my Shared Library class, I use it like below. GlobalVars.myVar = "" Try it like this and check. Here, I have decla

Re: Jenkinsfile Accessing variables from shared libraries

2020-12-16 Thread Adrian Wyssmann
I see several problem 1. using ' will not expand the parameters is your call should be sh "echo ${CustomMessage}" 2. CustomMessage is declared within the class Vars(), so you cannot access it You could implement a getter an then do something like this "echo ${globalVars.getCustomMe

Jenkinsfile Accessing variables from shared libraries

2020-12-16 Thread Kernel Panic
Hello there Maybe this is a very basic question, but am not being able to access a global variable from a shared library from a Jenkinsfile under vars I defined something like this globalVars.groovy class Vars () { def CustomMessage = "This is a new deployment" } from my Jenkinsfile libr