We are trying to use ${server.config.dir} in jvmOptions
-Djava.security.auth.login.config=${server.config.dir}/kerberos/client_jaas.conf
Can we set this as part of Jenkins environment variables?
We did it like this-
environment {
server.config.dir="some directory"
}
and we are getting this error-
WorkflowScript: 37: Expected string literal # line 37, column 9.
server.conf.dir="serverconfigdir"
^
The error message indicates a string literal is expected, and the special characters are causing the compiler to not read the key in the environment directive as a string literal. You need to explicitly cast it as a literal string:
environment {
'server.config.dir' = "some directory"
}
and the error will be fixed.
Related
I'm trying to execute a script to create a role in postgres
$PSQL_CLIENT "host=$servername user=$DB_POSTGRES_USERNAME dbname=postgres password='$DB_PASSWORD'"
the issue is with the password it has 6 words like(alpha beta charlie) and whitespaces and I'm not allowed to change it
I also tried:
$PSQL_CLIENT "host=$servername user=$DB_USERNAME dbname=postgres password=/"$DB_PASSWORD"/"
everytime I'm trying to connect I'm seeing this error
psql: warning: extra command-line argument "password content" ignored
psql: warning: extra command-line argument "password content" ignored
psql: warning: extra command-line argument "password content" ignored
psql: warning: extra command-line argument "password content," ignored
I think something has to be changed at password=/"$DB_PASSWORD"/" not sure what exactly needs to be done to read the password properly. Any help would be appreciated
As the documentation says:
To write an empty value, or a value containing spaces, surround it with single quotes, for example keyword = 'a value'.
So your command should work well for passwords containing spaces. You will still have a problem if your password contains ' or \, because
Single quotes and backslashes within a value must be escaped with a backslash, i.e., \' and \\.
So you need to use
IFS='' escapedpwd=$(echo "$DB_PASSWORD" | sed -e "s/\([\']\)/\\\\\1/g")
$PSQL_CLIENT "host=$servername user=$DB_POSTGRES_USERNAME dbname=postgres password='$escapedpwd'"
In Bazel, is it possible to use simple functions and variables as input to a load statement?
For example:
my_workspace = "a" + "b"
load(my_workspace, "foo")
load(my_workspace, "bar")
WARNING: Target pattern parsing failed.
ERROR: error loading package 'loadtest/simple': malformed load statements
The exact error message might have changed with version, I'd see:
syntax error at 'my_workspace': expected string literal
but no, you cannot use anything but string literal as per docs:
Use the load statement to import a symbol from an extension.
...
Arguments must be string literals (no variable)...
I tried to convert my OptaPlanner code from Java to Grails. Everything else is fine except I'm stuck when I changed the Planning Entity class into a Groovy file. Then Error message with this would show:
startup failed: F:\Users\Administrator\Documents\workspace-ggts-3.2.0.RELEASE\spa\src\groovy\optaplanner\domain\AllocationEntity.groovy: 15: Annotation list attributes must use Groovy notation [el1, el2] in #org.optaplanner.core.api.domain.variable.PlanningVariable # line 15, column 48. able(valueRangeProviderRefs = {"projects ^ 1 error
And my Intellij IDEA also would prompt an error message when I hover over the line #PlanningVariable(valueRangeProviderRefs = {"projectsRange"}) with red warning highlight under {"projectsRange"}, and the error message is this:
Cannot assign 'Class' to 'String[]'
I wish to use Groovy instead of Java for the GORM feature to query database. But how can I fix this error so I can use the Planning Entity as a Groovy class?
Most Java code is valid Groovy code, but there are a few exceptions, mostly when dealing with curly braces. Closures are defined in Groovy as a code block inside of curly braces, e.g.
def foo = {
...
}
so other uses of curly braces will confuse the Groovy parser. In most cases you just use regular braces instead. In this case your annotation list should be
#PlanningVariable(valueRangeProviderRefs = ["projectsRange"])
I am trying to use breakpoints for logging instead of NSLog, but I am having trouble accessing the "magic" compiler variables like __FUNCTION__, __FILE__, etc.
Neither Debugger Command nor Log Message breakpoints seem to evaluate the variables in the same way as NSLog.
NSLog(#"%s", __FILE__) results in correct debug output of /Users/nbirkholz/Documents/project_name/folder_name/file_name.m
When I set a Debugger Command breakpoint of po __FILE__ I receive debug output of "Parse" { 'P' 'a' 'r' 's' 'e' <nil>}
When I use p __FILE__ I receive debug output of (const char [6]) $1 = "Parse"
Similar results ensue from p/po __func__/__PRETTY_FUNCTION__/__FUNCTION__/__LINE__
po [NSString stringWithFormat:#"file is: %s", __FILE__] results in
error: too many arguments to method call, expected 1, have 2
po (void)NSLog(#"the file is: %s", __FILE__) returns <timestamp> <module> the file is: Parse
expr/expression (void)NSLog(#"the file is: %s", __FILE__) gives the same results.
Similarly, adding a Log Message breakpoint either fails to evaluate the expression at all or produces similar results, I can't seem to find an expression syntax that works encased in # #
For example a Log Message of the file is #__FILE__# begets the file is "Parse"
Is there a way to get this to work without adding an NSLog() to the code directly and get it to properly evaluate the variable?
These "Magic variables" are actually macros whose value is derived during compilation at the point they are referenced. They will not have the same value at debug time as they have at compile time. In fact, at debug time, you are most likely getting the variable's value as compiled into the debugger. I.E., not the file name of that code from MySpecialProgram, but the file name of the code executing in the debugger, likely the command parser.
Either put the logging in the code, as in:
NSLog(#"this is %s line %d function %s", __FILE__, __LINE__, __FUNCTION__);
or assign the vars to something you can access:
char[] foo = __FILE__;
I'm not sure here but afaik these are preprocessor macros, I think you can't get these to work in runtime.
Wondering if there is any thing wrong in this expression
${message(code:'${domianObject.paymentMode }.label', default:'Test')}
All I am doing is iterating over list of domain object and trying to replace value of an attribute using resource bundle.
Above code is resulting in weird parsing error
expecting ''', found '\r' # line 95, column 132.
${domianObject.paymentMode })
^
1 error
at java.lang.Thread.run(Thread.java:662)
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
I think that's a simple typo. Not domianObject but domainObject. Isn't it?
Nesting of gstring expressions can be a bit hairy, but once you're inside a ${} you can use any Groovy expression so instead of the inner gstring you can say
${message(code:(domainObject.paymentMode + '.label'), default:'Test')}
using normal string concatenation.