Trying to set value using powershell, in declarative pipeline

1,085 views
Skip to first unread message

itchymuzzle

unread,
Oct 26, 2017, 6:09:19 PM10/26/17
to Jenkins Users


#! /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

itchymuzzle

unread,
Oct 31, 2017, 8:51:29 AM10/31/17
to Jenkins Users

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.

Daniel Butler

unread,
Oct 31, 2017, 9:58:21 AM10/31/17
to jenkins...@googlegroups.com
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. 

--
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/3632e63e-f0c1-408a-b851-cd9ee98fe615%40googlegroups.com.

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

Reply all
Reply to author
Forward
0 new messages