Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Task to Setup Enviroment Variables #91

Open
mmattes opened this issue Aug 4, 2017 · 2 comments
Open

Use Task to Setup Enviroment Variables #91

mmattes opened this issue Aug 4, 2017 · 2 comments

Comments

@mmattes
Copy link

mmattes commented Aug 4, 2017

Hi,

it took me a while to figure out how I can use tasks to set Enviroment Variables which can be used during the whole deployment. I first tried the following

Deploy {

    By Task Set-Enviroment {        
     	$Env:Enviroment = "Dev"
        $Env:InstPath = "C:\Web\Precompiled\$Env:Enviroment.Website"        
        Tagged Dev
    }
    By Noop Test {
    	FromSource dist
    	To $Env:InstPath
    	DependingOn Set-Enviroment
    }
}

unfortunately this did not work out "By Noop Test" did not know anything about my enviroment variables. What worked out for me is to put the Enviroment variable within the task into the FromSource part like that:

Deploy {

    By Task Set-Enviroment {        
    	FromSource {
    		$Env:Enviroment = "Dev"
        	$Env:InstPath = "C:\Web\Precompiled\$Env:Enviroment.Website"        	
    	}     	
        Tagged Dev
    }
    By Noop Test {
    	FromSource dist
    	To $Env:InstPath
    	DependingOn Set-Enviroment
    }
}

The documentation does not say anything about that. I would like to complete the documentation but I dont know how it acutally is intended to be working? Is my approach by putting it into the FromSource correct?

@RamblingCookieMonster
Copy link
Owner

Hiyo!

Strange! I'll play around with it when I have a few minutes, might be a little while (about to head out of town).

Long story short, each layer dot sources the scriptblock... so in your working example:

  • Deploy sets up collection and...
  • Dot sources scriptblock for By Task
  • Dot sources nested FromSource
  • Dot sources scriptblock for By Noop

Something might be off in the logic - it seems like you should see the env bits you set even in your first example, as long as the task runs first, but there might be some oddity in the code.

Cheers!

@mmattes
Copy link
Author

mmattes commented Aug 5, 2017

Actually the only way it did work out for me in the end is to setup the enviroment variables in a powershell script before i call the Invoke-PSDeploy command. I have not managed to setup enviroment variables in a task so that another part of the psdeploy.ps1 file could pic the variables up then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants