I am trying to run a rake task that takes two parameters. These parameters are already stored as environment variables. I am getting what seems to be an escaping issue. What is wrong with this.
rake deploy:web_server[%parameter1%,%parameter2%]
I am getting this error message when I run this, where is my last squared bracket disappearing to?
Don't know how to build task 'deploy:web_server[param1_val,param2val'
I ended up figuring out that my %parameter2% environment value had a trailing space at the end. That is what was causing the issue. Have to be careful with spaces for environment variables.
Related
I encounter the issue that I have a parameterized project with several string parameters, e.g., "VARIABLE_A", and that Jenkins doesn't know them anymore when executing a shell script in the Build section, i.e., there is simply no value.
This is very bizarre and I am convinced this should work using a string parameter (variable) in these ways:
"echo $VARIABLE_A"
"python3 $PATH/abc.py $VARIABLE_A"
...
but there is no values anymore.
echo-command does not print anything and the Python script misses the value as VARIABLE_A is apparently empty.
Perhaps someone has an idea ?
Thanks
Rainer
PS
Jenkins version is "2.277.2".
I'm trying to inject an environment variable at build step Invoke Maven whose value was set at pre-build step through Execute Shell
#!/bin/bash
ipAddressHub=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' selenium-hub)
echo $ipAddressHub
echo 'ipAddress=$ipAddressHub' > ipAddress.properties
Now I want to fetch the value of ipAddress stored in ipAddress.properties. I'm using Inject environment variables after Execute Shell and provide ipAddress.properties in Properties File Path field (not sure if that's the right way) and then i use build step Invoke Maven Artifactory and provide the command below.
clean install -DipAddress=${ipAddressHub} -Denv=${env} -Durl=${appURL} -DserverIP=${ipAddress}
But i don't get the value in serverIP, instead i get ${ipAddressHub} in console. I know i'm making some mistake, can anybody point out what's the correct way?
I hadn't used the plugin (at least not for a while), and I was going to suggest that you are just referencing it incorrectly?
I believe if you are adding it as an environment variable (and you can check it is adding by clicking on Environment Variables on the left side of the build screen).
You should be able to reference it like below?
${env.ipAddressHub}
This is untested though. Just going from memory.
Did some browsing and found an answer to it.
You can embed variables only in double-quoted strings. So the problem was
echo 'ipAddress=$ipAddressHub' > ipAddress.properties
changed it to
echo 'ipAddress='"$ipAddressHub"' > ipAddress.properties
And it worked like a charm
I'm trying to set up a Jenkins job that is parametrized with an svn revision number, called param.svn.revision, entered by a user.
During the execution, I want to launch a maven command like :
clean package -Dsvn.revision=$param.svn.revision
I tried a lot of thing instead of $param.svn.revision, like ${param.svn.revision}, "$param.svn.revision", "%param.svn.revision",... but nothing worked.
What have I to do to make it work ?
Thanks a lot,
Seb
Because this is an invalid shell expansion. Shell doesn't expect dots within variable names. You should remove the dots in the param name in order to successfully use it.
I've pulled a few scripts into Jenkins for a proof of concept and think I'd like to move that direction for all of our scripts. Right now I keep an environment.rb file with my code (watir-webdriver, cucumber) which tells the script which environment we're testing and which browser to use (global variables). Jenkins fires off the script using rake.
I'd love to let the user choose the environment and browser through Jenkins 'choice' variable or similar, and then pass that to the script. While I see the framework in that for Jenkins and set up a choice list for environment, I'm having trouble determining what the next step is.
I could write to environment.rb, I could pass a variable to rake - I have many options for how to pass the information, I just need some assistance finding the first step to find the Jenkins way of accomplishing them. Google results and previous Stack questions weren't what I was looking for.
Thanks
Sure. Give the user either a text entry field a dropdown after telling Jenkins that this is a parameterized build. You'll give them a name, something like BuildEnvironment. Then when you call the build, you can pass these from the environment variables. For example, if you were using ANT, you'd add a line to the parameters that said environment = ${MyEnvironment} Jenkins will then pass the value along for your build tool to use.
There is a way to pass Jenkins Environment Variable to Ruby script. Please see the following example:
workspace_path = `echo $WORKSPACE`.strip # note the use of backticks
puts workspace_path
In the "echo $WORKSPACE".strip # the code work only if you replace quotes with backticks
This code example works in Jenkins on a Linux system.
Every time that I try use team city to build a .NET solution using rake I receive the same
"Format_exception_msg : Invalid escape character syntax: /path to rakefile/ (RegexError)
My natural assumption would be that I have in fact a invalid escape character somewhere in my rake code, I admit that I've never used ruby or rake before, but the script itself executes without problems and behaves as it should when executed on the command line without the use of teamcity.
Furthermore, I went through my code slowly commenting out lines to try to narrow down where the invalid character could be and the team city process continuted to fail even with a completely commented out rake file.
Thanks for the help, let me know if more information is needed.