Jenkins envInject Plugin not picking PATH - jenkins

I have my Jenkins configured to Inject environment variables to the build process and set the Properties File Path to G:\Jenkins\env.properties
Inside my env.properties
VISUALSTUDIOVERSION=12.0
PATH=$PATH
When I run my job, the PATH is not reflecting my system path instead its just showing $PATH only. How can I edit my env.properties file to pick up system PATH?
THe output of Env variables after build is
VISUALSTUDIOVERSION=12.0
PATH=$PATH
But I am expecting to see it as
VISUALSTUDIOVERSION=12.0
PATH=C:\Program Files (x86)\Perl\site\bin;C:\Program Files (x86)\Perl\bin;

Environment variables in Java are case-sensitive. Try Path instead of PATH.

Related

Ant is not recognized error in JMeter reports

I am struggling an issue to run ant with JMeter.
I downloaded apache-ant-1.10.3-bin.zip and put it in C:\ant
I extract the ZIP and it created another ant folder (see pic), this is the bin folder C:\ant\ant\bin
I entered to control panel -> system properties -> Advanced tab -> Environment Variables
Under user variables under path I entered ;C:\ant\ant\bin
Under System variable I enter Variable ANT_HOME and value C:\ant\ant\bin
I opened cmd and run ant -version
I got 'ant' ant is not recognized as as internal
what am I missing?
[][path of extracted zip]
[][path of bin file]
[][enter bin file]
[][system variable]
[][system variable2]
[][error in cmd]
ANT_HOME variable should be set to the main folder of ant and not c:\ant\ant\bin
Set the variable name to ANT_HOME and the variable value to apache-install-dir\apache-ant-version and click OK.
For example, the installation directory might be C:\Java\apache-ant-1.7.0.
Select New again to create the ANT_OPTS environment variable.
Set the variable name to ANT_OPTS and the variable value to -Xms256M -Xmx512M and click OK.
Select the PATH environment variable and select Edit.
Add %ANT_HOME%\bin to the end or beginning of the PATH.
In your case set it to
c:\ant\ant

Jenkins Publish Over SSH Plugin filename variable

I have a Jenkins job that invoke a gradle script to create a .war file from sources.
gradle war command produces a file with name Geo-1.0.5.war because build.gradle use version number:
war {
baseName = 'Geo'
version = '1.0.5'
}
This file will be copied and deployed on a Wildfly server trough SSH using "Publish Over SSH Plugin".
How can I tell to the plugin that the war filename format is something like Geo-$gradle_version.war?
This is documented if you click the (?) help icon next to the "Source files" field within Jenkins:
The string is a comma separated list of includes for an Ant fileset eg. **/*.jar
(see Patterns in the Ant manual).
So in your case, you could use **/Geo-*.war as the source pattern.
This is also shown in the screenshot on the plugin wiki page, and in the Source Files and Examples sections on the linked "Publish Over…" documentation.
In your comment to this answer, you mention that you don't want to communicate that the filename is "something like Geo-$gradle_version.war" for uploading, but rather want to use the exact filename in a script being executed on the SSH host.
You could do this by adding an Execute Shell step which determines the filename, and exporting it as an environment variable using the EnvInject Plugin. For example:
f=$(basename `find . -name 'Geo-*.war'`)
echo WAR_FILENAME=${f} > env.properties
Then, by using an Inject Environment Variables step with its path set to env.properties, the WAR_FILENAME value will be added to the build environment, available for use by subsequent steps.
In the Exec Command field of the SSH-publishing step, you can then use ${WAR_FILENAME} to refer to the exact filename uploaded.

Add liquibase to PATH not recognized

I downloaded the latest Liquibase .zip file from http://www.liquibase.org/download/index.html
Then, I added the path to my liquibase.bat file (C:\liquibase-3.5.3-bin) to my Environment Variables: User variable PATH and System Variable PATH.
However, the command liquibase is still not recognized in the commandline. Am I missing something for liquibase?
Thanks.

Is it possible to use environment variable in sonar-project.properties file

I am executing sonar through Jenkins build, there is use-case where 'src' location changes depending upon build so i want to use environment variable for specifying 'src' path.
For example in sonar-project.properties i want to specify as shown below:
src= c:/project/workspace instead i want to use src =${SONAR_RUN_WORKSPACE}
Environment variables are supported in sonar-project.properties starting from SonarQube Scanner version 2.9 (see SQSCANNER-9).
So, this should work now:
sonar.sources=${env.SONAR_RUN_WORKSPACE}
You cannot pass env variable into sonar-project.property file.
If you are creating sonar-project.property file from jenkins, you can use build with param.
(or)
Create a sonar-project.properties without sonar.source.
Create build with param variable {path}, get the src path from user for each build,
Map the variable with sonar.source=${path} in sh.
Append sonar.source to sonar-project.properties for each build in sh using (>>) or cmd from jenkins.
eg) sonar.source="path" >> sonar-project.properties
finally work space contains sonar-project.properties file with src path.
Nope, environment variables are not supported in sonar-project.properties. In any case, back to your use-case: you better use a relative path for sonar.sources so that, wherever analysis is ran (i.e. whatever workspace with Jenkins), sources are always found at the expected place (from the project's base directory).

How to set Jenkins installation file location?

I want to set Jenkins file location to E:\Programs\Jenkins kind of location
I'm using the command java -jar jenkins.war
How do i specify the file location with that commad
I think you mean jenkins home. Just specify JENKINS_HOME environment variable before launching jenkins. If you are using Windows go to user accounts configuration and change your environment variables. Add variable JENKINS_HOME with value E:\Programs\Jenkins.

Resources