env.WORKSPACE returns null on pipeline

332 views
Skip to first unread message

Thiago Carvalho Davila

unread,
May 22, 2017, 10:56:22 AM5/22/17
to jenkins...@googlegroups.com
Hi,

I am trying to get WORKSPACE folder from jenkins global enviroment variables. The strange thing is I get null on the response:

PATH_CI_TOOLS="${env.WORKSPACE}\\tools_ci"
pipeline {
    stages {
        stage('Test'){
            steps{
                bat "${PATH_CI_TOOLS}\\MyProject.exe"
            }
        }
    }
}



Return:
null\tools_ci\MyProject.exe
The system cannot find the path specified.

-


"Esta mensagem do SERVIÇO FEDERAL DE PROCESSAMENTO DE DADOS (SERPRO), empresa pública federal regida pelo disposto na Lei Federal nº 5.615, é enviada exclusivamente a seu destinatário e pode conter informações confidenciais, protegidas por sigilo profissional. Sua utilização desautorizada é ilegal e sujeita o infrator às penas da lei. Se você a recebeu indevidamente, queira, por gentileza, reenviá-la ao emitente, esclarecendo o equívoco."

"This message from SERVIÇO FEDERAL DE PROCESSAMENTO DE DADOS (SERPRO) -- a government company established under Brazilian law (5.615/70) -- is directed exclusively to its addressee and may contain confidential data, protected under professional secrecy rules. Its unauthorized use is illegal and may subject the transgressor to the law's penalties. If you're not the addressee, please send it back, elucidating the failure."

Dzmitry Kashlach

unread,
May 23, 2017, 2:53:40 AM5/23/17
to Jenkins Users, thiago...@serpro.gov.br
It happens because EnvVars object contains less variables in "pipeline" mode than in "Freestyle". 

Do not know how to deal with it in your case.

Stephen Connolly

unread,
May 23, 2017, 4:31:04 AM5/23/17
to jenkins...@googlegroups.com
The pipeline script is executed on the master. Only when you are within scope of an actual agent node will the workspace have been assigned, so the example you are doing will be expected to return null as you are outside the pipeline {} entirely

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7997bcf2442a04c5248cd939681e37c4a53b7685%40serpro.gov.br.
For more options, visit https://groups.google.com/d/optout.

Thiago Carvalho Davila

unread,
May 23, 2017, 10:22:14 AM5/23/17
to jenkins...@googlegroups.com
Sorry Stephen, I omitted the agent part (and the rest of the pipeline) for the sake of conciseness, to isolate the problem. But the pipeline script is being executed on the slave.

More acurate version:

PATH_CI_TOOLS="${env.WORKSPACE}\\tools_ci"
pipeline {
    agent {
        label 'myslave'

    }
    stages {
        stage('Test'){
            steps{
                bat "${PATH_CI_TOOLS}\\MyProject.exe"
            }
        }
    }
}

Thanks,

Thiago
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CA%2BnPnMxSeV6sEqDD%3DTxgUMj-Eucr6StNhhiTKMcmr44htvO3rg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

Stephen Connolly

unread,
May 23, 2017, 10:29:13 AM5/23/17
to jenkins...@googlegroups.com
On 23 May 2017 at 07:21, Thiago Carvalho Davila <thiago...@serpro.gov.br> wrote:
Sorry Stephen, I omitted the agent part (and the rest of the pipeline) for the sake of conciseness, to isolate the problem. But the pipeline script is being executed on the slave.

More acurate version:

PATH_CI_TOOLS="${env.WORKSPACE}\\tools_ci"

^^^ oh look this is outside of the stages stanza like I originally said
 

-


"Esta mensagem do SERVIÇO FEDERAL DE PROCESSAMENTO DE DADOS (SERPRO), empresa pública federal regida pelo disposto na Lei Federal nº 5.615, é enviada exclusivamente a seu destinatário e pode conter informações confidenciais, protegidas por sigilo profissional. Sua utilização desautorizada é ilegal e sujeita o infrator às penas da lei. Se você a recebeu indevidamente, queira, por gentileza, reenviá-la ao emitente, esclarecendo o equívoco."

"This message from SERVIÇO FEDERAL DE PROCESSAMENTO DE DADOS (SERPRO) -- a government company established under Brazilian law (5.615/70) -- is directed exclusively to its addressee and may contain confidential data, protected under professional secrecy rules. Its unauthorized use is illegal and may subject the transgressor to the law's penalties. If you're not the addressee, please send it back, elucidating the failure."

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages