Vsts构建定义 - 防止PowerShell退出行为导致进程终止(VSTS build definition - prevent PowerShell exit behavior causing processes termination)
所以我在我的定义中有一个PS任务,它自己调用另一个脚本文件,负责在我的构建代理上运行几个东西(启动几个不同的进程) - 模拟器, node.js应用程序等。一切都很好,直到这一步完成并继续运行。 所发生的是所有上述内容都被关闭,大多数底层进程被杀死,因此,任何进一步的执行(例如测试运行)都注定要失败。
我的假设是这些进程以某种方式依赖于VSTS生成的最外层(临时)脚本来处理该步骤。 我尝试使用我的脚本的参数列表中指定的-NoExit开关,但无济于事。 我还在某处读到了一个建议,默认情况下使用powershell.exe的注册表项设置它 - 仍然没有。
在詹金斯,同样的工作流程也没问题。 所以我想知道是否有人经历过这个并且可以提供帮助? 先谢谢你。
编辑
所以这些是我的任务: VSTS任务
最后一个PowerShell任务调用指定的PS文件,该文件自己调用其他几个文件。 它们确保了开始执行测试所需的一些本地依赖项和进程,例如运行的node.js应用程序(例如,在单独的控制台中启动并运行正常)。 当任务完成并且成功时,带有测试的最后一个将失败,因为node.js应用程序已关闭,以及在上一步骤中启动的任何其他应用程序。 它只是阻止一切。 这就是为什么我目前正在同一个任务中运行测试,直到我找到如何克服这种行为。
I have a PowerShell task in my definition that calls another script file on its own which takes care of running several things on my build agent (starts several different processes) - emulators, node.js applications, etc.
Everything is fine up until the moment this step is done and the run continues. All of the above mentioned stuff gets closed with most of the underlying processes killed, thus, any further execution (e.g. tests run) is doomed to fail.
My assumption is that these processes are somehow dependent on the outermost (temporary) script that VSTS generates to process the step.
I tried with the -NoExit switch specified in the arguments list of my script, but to no avail. I've also read somewhere a suggestion to set this by default with a registry key for powershell.exe - still nothing.
The very same workflow was okay in Jenkins. How can I fix this?
These are the tasks I have:
The last PowerShell task calls a specified PowerShell file which calls several others on its own. They ensure some local dependencies and processes needed to start executing the tests, e.g. a running Node.js application (started in a separate console for example and running fine).
When the task is done and it is successful, the last one with the tests would fail because the Node.js application has been shut down as well as anything else that was started within the previous step. It just stops everything. That's why I'm currently running the tests within the same task itself until I find out how to overcome this behavior.
原文:https://stackoverflow.com/questions/43203959
最满意答案
从命名捕获组中删除
=
..另外..您的最后一组未关闭!\s*(\d+).*changed,\s+(\d*)(?P<in>\s+insertion).*(\d+)(?P<del>\s+deletion).* ↑ ↑ ↑
见DEMO
编辑:改进
+
和-
正则表达式以及命名的数字捕获:\s*(\d+)\s+files?\s+changed,\s*((?P<in>\d+)\s*(insertions?)\([+-]\))?,?\s*((?P<del>\d+)\s*(deletions?)\([+-]\))?
见DEMO
Remove
=
from named capture group.. Also.. your last group is not closed!\s*(\d+).*changed,\s+(\d*)(?P<in>\s+insertion).*(\d+)(?P<del>\s+deletion).* ↑ ↑ ↑
See DEMO
Edit: Improved regex for
+
and-
too and named capture of digits:\s*(\d+)\s+files?\s+changed,\s*((?P<in>\d+)\s*(insertions?)\([+-]\))?,?\s*((?P<del>\d+)\s*(deletions?)\([+-]\))?
See DEMO
相关问答
更多-
正如您所见, \p{L}中的unicode字符类在re模块中不可用。 但是,这并不意味着您无法使用re模块执行此操作,因为\p{L}可以使用UNICODE标志替换为[^\W\d_] (即使这两个字符类之间存在细微差别,请参阅评论中的链接)。 第二点,你的方法不是好的方法(如果我理解得很好,你试图提取每一行的最后一个单词)因为你奇怪地决定删除所有不是最后一个单词(换行符除外)的替换。 〜52000步骤提取10行文本中的10个单词是不可接受的(并且会因更多字符而崩溃)。 更有效的方法是找到所有最后的单词,请参阅 ...
-
看看实际的比赛会让你知道发生了什么。 >>> re.match(r'(\w+)', 'a-b') <_sre.SRE_Match object at 0x0000000002DE45D0> >>> _.groups() ('a',) 正如你所看到的,表达式匹配a 。 字符序列\w只包含实际的单词字符 ,但不包含破折号等分隔符。 所以你不能使用\w+来实际匹配ab 。 现在,在第二个表达式中,可能会认为它至少与b:1匹配,因为\w+与b匹配,并且:(\d+)与1匹配。 但是,由于re.match工作原理,它 ...
-
感谢所有, 在思考了一下之后,我想到了这一点,在实现正则表达式之前,我并没有考虑回车: import os import sys import getpass import re import telnetlib HOST = "ip address" user = raw_input("Enter your remote account: ") password = raw_input("Enter the password: ") tn = telnetlib.Telnet(HOST) tn.re ...
-
从命名捕获组中删除= ..另外..您的最后一组未关闭! \s*(\d+).*changed,\s+(\d*)(?P
\s+insertion).*(\d+)(?P \s+deletion).* ↑ ↑ ↑ 见DEMO 编辑:改进+和-正则表达式以及命名的数字捕获: \s*(\d+)\s+files?\s+changed,\s*((?P\d+)\s*( ... -
这应该工作: print(re.findall(r"(HEADER_.*)\s*?\t*?=\s*\t*((\d|[x0-9A-Fa-f])*)", text)) [('HEADER_CG_HANDSHAKE\t\t\t\t', '0xff', 'f')] 你的正则表达式在开始时有一个额外的[^\/] 。 顺便说一句你的Python输入与regex101上的输入不同,因为Python代码中缺少前导空格。 This should work: print(re.findall(r"(HEADER_.*)\s* ...
-
如何删除diffstat计数和新添加的文件到LOC计数?(How to make diffstat count removed and newly added files to LOC count?)[2023-09-09]
更简单: diff -urN dir1/ dir2/ |diffstat 使用GNU diff的-N选项,例如,在比较目录时 : 如果只存在一个文件,则diff通常不显示其内容; 它仅报告一个文件存在但另一个文件不存在。 您可以使diff操作好像丢失的文件为空,以便它输出实际存在的文件的全部内容。 (它将作为插入或删除输出,具体取决于丢失的文件是在第一个位置还是第二个位置。)为此,请使用--new-file ( -N )选项。 Simpler: diff -urN dir1/ dir2/ |diffsta ... -
Python - 显示Findall之前和之后的键值(正则表达式,输出)(Python - Display key values before and after Findall(regex, output))[2021-12-06]
如果我理解正确,您可以搜索模式[InstanceID: ...]以获取实例ID,并使用PermanentMACAddress = ...来获取MAC地址。 这是一种方法: import re match_inst = re.search(r'\[InstanceID: (?P[^]]*)', output) match_mac = re.search(r'PermanentMACAddress = (?P .*)', output) inst = match_inst.groupdi ... -
Python正则表达式匹配(Python regex matching)[2023-06-28]
这样做你想要的吗? import re def extract_from_string(s): match = re.search('(?<=\))\w*?(?=:)', s) return match.group(0) if match else None if __name__ == '__main__': s1 = 'MsgTrace(65/26)noop:user=xxx=INBOX:cmd=534' s2 = 'ImapFetchComplete(56/39 ... -
Python程序和正则表达式(Python program and regex)[2022-06-28]
测试多种模式 要测试多个复杂模式,您需要在一个循环中添加这些测试,并且只循环遍历数据文件。 那就是你想要下面的代码: for line in data : # If line has 'Deny ' in it, then check it some more if 'Deny ' in line: seen.update(DENY_PATTERN.findall(line)) # If line has 'ASA-3' ... -
您需要在[AZ]+之前允许任何符号: >>> import re >>> s = 'ABCa4.daf<
>permission : wiadsfth.accedsafsds.INTERNET< >' >>> re.findall('< >.*?([A-Z]+)< >', s) ['INTERNET'] .*? 是任何角色的非贪婪匹配。 [AZ]+匹配1个或更多大写字母。 You need to allow any symbols before the [A-Z]+ ...