-1

I have a 'Deploy a nuget package' step in Octopus. In that step, I want to deploy a nuget package and have some deployment script executed.

Now I want the deployment to happen only for master and hotfix branches.SO I added a condition like this in the deployemnt script:

 if ($BranchName.ToLower().equals("master") -or $BranchName.ToLower().contains("hotfix")) 
 {
  ...................
 }

But it doesn't work and I am gettin error like this

 'You cannot call a method on a null-valued expression.'

How can I achieve this?

Note: I don't have any pre-deployment and post-deployment script

coder coder
  • 53
  • 1
  • 7
  • Your code works fine as long as `$branchname` contains data and is a string. The error is pretty clear so far. `$branchname` appears to be null. how do you populate it? – Matt Sep 30 '15 at 04:03

1 Answers1

0

Are you able to check if $BranchName is null? You can also compare strings with inbuilt operators:

if ($BranchName -and ($BranchName -ilike "master" -or $BranchName -ilike "*hotfix*"))
 {
  ...................
 }
xXhRQ8sD2L7Z
  • 1,686
  • 1
  • 14
  • 16