Trying to set value using powershell, in declarative pipeline

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Trying to set value using powershell, in declarative pipeline

itchymuzzle


#! /usr/bin/env groovy
pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                script {
                    powershell '$env:Path'
                    powershell '$env:PYTHONPATH'
                    powershell '$env:PYTHONPATH = "../../dir" '
                    powershell '$env:PYTHONPATH'

 

The value for Path is printed, but nothing else.


The snippit generator gives me that syntax. 


The other confusing thing is that I get the same result with and without the PowerScript plugin.  So don’t understand what the plugin is supposed to be giving me.


Thanks

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e62b09fe-9f08-4f5a-b050-a110966e7136%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Trying to set value using powershell, in declarative pipeline

itchymuzzle

Doesn’t answer my original question, but is a valid work around. 

 

#! /usr/bin/env groovy
pipeline {
    agent {label 'windows'}
    parameters {
        string(name: 'Version', defaultValue: '0.1', description: 'What is the release version?')
    }
    environment {
        PYTHONPATH = "../DifferentDir"
    }
    stages {
        stage('Build') {
            steps {
                script {
                    powershell '''
                    cd WebApp;
                    ..\\..\\..\\..\\Python27\\Lib\\venv\\scripts\\nt\\Activate.ps1;
                    python -m BuildTools.build_codebase $env:Version clean package
                    '''
                }
            }
        }

 

This is without the Powershell plugin, still don’t understand what that plugin does.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3632e63e-f0c1-408a-b851-cd9ee98fe615%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Trying to set value using powershell, in declarative pipeline

danielsimonbutler
The powershell step in pipeline is provided by the same plugin that provides the bat and sh steps.  It's  separate to the powershell plugin which is for freestyle jobs. 

On 31 Oct 2017 12:51 pm, "itchymuzzle" <[hidden email]> wrote:

Doesn’t answer my original question, but is a valid work around. 

 

#! /usr/bin/env groovy
pipeline {
    agent {label 'windows'}
    parameters {
        string(name: 'Version', defaultValue: '0.1', description: 'What is the release version?')
    }
    environment {
        PYTHONPATH = "../DifferentDir"


    }
    stages {
        stage('Build') {
            steps {
                script {
                    powershell '''
                    cd WebApp;
                    ..\\..\\..\\..\\Python27\\Lib\\venv\\scripts\\nt\\Activate.ps1;
                    python -m BuildTools.build_codebase $env:Version clean package
                    '''
                }
            }
        }

 

This is without the Powershell plugin, still don’t understand what that plugin does.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3632e63e-f0c1-408a-b851-cd9ee98fe615%40googlegroups.com.

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

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO37hbjrBsdNi0syU%3De1uqU7kV1tRYB_hPtFdTs068rM8FGq3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.