Unable to grep output of command #25935
-
I have a step that runs a script to deploy a revision to google cloud endpoints and then get the configuration ID from that. The script works perfectly in the local environment but fails to grab the configuration ID in the github actions runner. The relevant lines in the script follow:
On the last line, the The step is:
|
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
In GitHub Actions workflow, environment variables are case-sensitive. From your comments,
I notice the variable name “CONFIG_ID” is completely uppercase. But in the script,
you are using the variable name “config_id” that is completely lowercase. Please change the variable name to uppercase (echo “ConfigID: ${CONFIG_ID}”) in the script to see if the problem can be solved. |
Beta Was this translation helpful? Give feedback.
-
@brightran That’s the header text in the command output, not an actual variable. The variable As a note, though, I updated the whole thing from a shell script to a python script and it is now working fine, so my immediate issue is resolved. The python script does not have the same issue with the regular expression matching. What I’d be interested in knowing, however, is what the issue is in the workflow run that causes the |
Beta Was this translation helpful? Give feedback.
-
Ah, yes, I missed it. In the grep command, it seems does not recognize the metacharacter ‘\d’ in the regular expression “\d+\-\d+\-\d+[a-z]\d+”. I tested on my local environment (Windows 10, Bash), and only when I used the metacharacter ‘[0-9]’, the configuration ID can be fetched. When using '\d‘, it returned nothing.
|
Beta Was this translation helpful? Give feedback.
-
Ah that’s interesting. I didn’t consider that the regex would be supported differently across environments. After some testing, I’ve found that on my that macOS command line, Thanks for the tip! |
Beta Was this translation helpful? Give feedback.
-
The issue is the use of I guess grep on MacOS has different defaults there. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reminder. I just remembered that there are many regular expression flavors. The popular regular expression flavors include Perl, PCRE, PHP, .NET, Java, JavaScript, XRegExp, VBScript, Python, Ruby, Delphi, R, Tcl, POSIX, etc… When using the option ‘-E’ (–extended-regexp), it is specified by POSIX. |
Beta Was this translation helpful? Give feedback.
-
@airtower-luna @brightran Yep, I see that now. That you guys for the help! I’m all set. |
Beta Was this translation helpful? Give feedback.
@therealkris,
Ah, yes, I missed it.
Now I seem find the reason that way the command fails to get the configuration ID.
In the grep command, it seems does not recognize the metacharacter ‘\d’ in the regular expression “\d+\-\d+\-\d+[a-z]\d+”.
I know, generally many people (include me) are used to using the metacharacter ‘\d’ instead of '[0-9]‘ to represent the digital characters in the regular expression.
However, I find that some command line interfaces do not recognize the metacharacter ‘\d’, and they seem to prefer the metacharacter '[0-9]‘.
Maybe in some environments, the …