从 git-ci ssh 进入 windows 服务器并执行带参数的 powershell 函数
ssh into windows server from git-ci and execute a powershell fucntion with parameter
从我的 git 服务器通过 ssh 连接到我的 windows 服务器后,我试图在我的 powershell 文件中执行一个 powershell 函数。
这是我正在使用的代码:
script:
stage: before_merge
script:
- sshpass -p <<password>> ssh user@host powershell.exe -File G:\test\Scripts\test1.ps1 -Command "test 2"
only:
- merge_requests
这是test1里面的代码。ps1
function test($no){
$message = "test" + $no
Add-Content G:\MIERUKA\Scripts\test1.txt $message
}
当我 运行 来自 git-ci 的 ci 代码时,结果本身是成功的。但是,该文件未创建。就像我的功能没有首先执行一样
稍作调整后,得到了我的答案。
这是我使用的代码:
script:
stage: before_merge
script:
- sshpass -p <<password>> ssh user@host "cmd.exe /c powershell.exe G:\path\toScripts\test1.ps1; "test 2""
only:
- merge_requests
从我的 git 服务器通过 ssh 连接到我的 windows 服务器后,我试图在我的 powershell 文件中执行一个 powershell 函数。
这是我正在使用的代码:
script:
stage: before_merge
script:
- sshpass -p <<password>> ssh user@host powershell.exe -File G:\test\Scripts\test1.ps1 -Command "test 2"
only:
- merge_requests
这是test1里面的代码。ps1
function test($no){
$message = "test" + $no
Add-Content G:\MIERUKA\Scripts\test1.txt $message
}
当我 运行 来自 git-ci 的 ci 代码时,结果本身是成功的。但是,该文件未创建。就像我的功能没有首先执行一样
稍作调整后,得到了我的答案。 这是我使用的代码:
script:
stage: before_merge
script:
- sshpass -p <<password>> ssh user@host "cmd.exe /c powershell.exe G:\path\toScripts\test1.ps1; "test 2""
only:
- merge_requests