title: Remove remote branch from a Jenkins job
body: <p>I have a maintenance job in <strong>Jenkins</strong> for my <strong>Git</strong> repository (<strong>git on TFS online</strong>) to remove branches that don't match specific conditions or stale branches. When running the job it says this:</p>
  
  <pre><code>Going to remove branch development/Batch_R7
  fatal: InvalidOperationException encountered.
     Showing a modal dialog box or form when the application is not running in 
  UserInteractive mode is not a valid operation. Specify the ServiceNotification 
  or DefaultDesktopOnly style to display a notification from a service 
  application.
  bash: /dev/tty: No such device or address
  error: failed to execute prompt script (exit code 1)
  fatal: could not read Username for 'https://everisidbtfs.visualstudio.com': No 
  error
  </code></pre>
  
  <p>I run this command from a <strong>Powershell</strong> script.</p>
  
  <p>Other Git commands work fine in that Powershell script, for example to get a list of branches.</p>
  
  <p>If I run the PowerShell script from the Powershell command line in the Jenkins server (or in any other machine) it works fine.</p>
  
  <p>The TFS user has permissions to remove remotes and credentials are provided to the Jenkins job.</p>
  
  <p>This is the Git command I use to remove branches:</p>
  
  <pre><code>git push --porcelain --progress --recurse-submodules=check origin :refs/heads/&lt;branch_name&gt;
  </code></pre>
  
  <p>Is there any workaround for this? What am I doing wrong?</p>
  
  <p>It comes to my mind that, since the git command is a "write" operation (a push), maybe there's some security limitation in Jenkins to do that... The rest of the git commands I use in automation scripts are "readonly".</p>