I have a script which runs a Jenkins job using buildWithParameters. The values given here contain "#" and this character is recognized as a comment, not as a character from that value:
http://jenkins:8080/job/test/buildWithParameters?token=token&var1=test#1&var2=test#2
In job var1 is test and var2 has no value.
Can you help me to resolve this issue?
I have found the solution. The "#" was replaced with "%23", the hex code of #.
http://jenkins:8080/job/test/buildWithParameters?token=token&var1=test%231&var2=test%232
Related
I have windows 10 and installed GNU Make 4.3 Built for Windows32. This is my first time using GNU make and it gave me an error like this
.env:6: *** unterminated variable reference. Stop.
my .env file contain
POSTGRES_USER="postgres"
POSTGRES_PASS="<MY_DB_PASS>"
POSTGRES_DB="<MY_DB>"
PG_HOST="localhost"
PG_PORT="5432"
SECRET_KEY="<MY_SECRET_KEY>"
DEBUG=True
ALLOWED_HOSTS="localhost 127.0.0.1"
You may think that you're saving yourself by adding quotes. And, if this variable is parsed by a shell then you are.
But, make doesn't use quotes. The value of a variable is the complete contents to the right of the equal sign (after any initial whitespace is skipped). So for example:
POSTGRES_USER="postgres"
If parsed by the shell, the value of the POSTGRES_USER variable is postgres because the shell interprets the quotes. But make doesn't interpret quotes so the above line results in POSTGRES_USER make variable having the value "postgres" (including the quotes).
Now for your issue. Line 6 of your file is:
SECRET_KEY="<MY_SECRET_KEY>"
and you don't show us the text of your secret key.
First, this is wrong even in shell syntax: you must use single-quotes here not double quotes, and even that will not be right if your secret key contains single quotes itself; you'd have to escape that.
However that error means that in your secret key you have the character sequence $( or ${ which make interprets as starting a variable reference: since there is no close paren or brace you get this error.
The short answer is, there's no portable way to use the same file sourced by both make and the shell if the values of the variable assignments contain any sort of special character (including whitespace).
Usually people do something like base64 encode their secret keys, so that those special characters are not a problem.
In my pipeline I have a variable abd with value "xyz #123".
I need to get only numeric value after special character #,
How do I achieve this in Jenkins Pipeline?
You can do this in Groovy fairly simply (if your string always matches that pattern):
abc.substring(abc.indexOf('#') + 1, abc.length())
That will give you the string 123.
I'm on my very first script with kapacitor. I've written a tick file. Following is the script.
stream
.from().measurement('cpu')
.where("cpu" == 'cpu-total')
.alert()
.info(lamda:TRUE)
.log('/tmp/cpu.log')
I'm defining tick file to kapacitor using following command
kapacitor define highcpu -type stream -dbrp telegraf.default -tick cpu.tick
Getting Following error
invalid TICKscript: parser: unexpected unknown state, last char: ':' line 5 char 14 in "info(lamda:TRUE)". expected: ")"
I'm not getting exactly going wrong. I'm sure there is nothing wrong with config and telegraf and influxdb.
Kapacitor version 1.3.1
OS: Fedora 22
Missing 'b' in lamda.
Should be: lambda.
Q: I'm not getting exactly going wrong.
A: Short answer, syntax error.
Unfortunately the parser for Kapacitor's TICK script is not that mature yet and you really can't blame them for it. This project is still a baby, hence these such of errors only appear during runtime.
The problem is with your lambda expression .info(lamda:TRUE). You need to tell the expression which field or tag to lookup its value.
A typical lambda expression looks like
info(lambda: if ("sum" >= 45000, '1', '0'))
info(lambda: "isPeakHour" == 'true')
Something to note here is that, there is no True or False in Kapacitor yet. 1 or 0 is typically used to represent boolean.
You might also want to take note of single quote and double quotes in TICK script.
Single quotes are string literals
Double quotes are references to a field or tag. Double quotes are
only used in lambda expressions.
Here is my sample string.
[echo] The SampleProject solution currently has 85% code coverage.
My desired output should be.
The SampleProject solution currently has 85% code coverage.
Btw, I had this out because I'm getting through the logs in my CI using Jenkins.
Any help? Thanks..
You can try substText parameter in BUILD_LOG_REGEX token to substitute the text matching your regex
New optional arg: ${BUILD_LOG_REGEX, regex, linesBefore, linesAfter, maxMatches, showTruncatedLines, substText} which allows substituting text for the matched regex. This is particularly useful when the text contains references to capture groups (i.e. $1, $2, etc.)
Using below will remove prefix [echo] from all of your logs ,
${BUILD_LOG_REGEX, regex="^\[echo] (.*)$", maxMatches=0, showTruncatedLines=false, substText="$1"}
\[[^\]]*\] will match the bit you want to remove. Just use a string replace function to replace that bit with an empty string.
Andrew has the right idea, but with Perl-style regex syntaxes (which includes Java's built-in regex engine), you can do even better:
str.replaceAll("\\[.*?\\]", "");
(i.e., use the matching expression \[.*?\]. The ? specifies minimal match: so it will finish matching upon the first ] found.)
I am writing an ant build script that does a sshexec and returns the output of the command ran into the outputproperty attribute.
The value of the outputproperty has a newline character on the end of them. Anyway I can strip that newline character from the output?
Regards,
Stephen
I managed to find the answer: The newline character represented by 
 can be used when using the <equals> command.
Regards,
Steve