Jenkins -Gradle -Java - arrays

I am trying to parameterize my build in Jenkins by taking two variables and pass it to gradle build file which should finally be used by my java file. How could I achieve this?

See Jenkins, Parameterized Build:
Sometimes, it is useful/necessary to have your builds take several "parameters".
[...]
The parameters are available as environment parametersvariables. So e.g. a shell ($FOO, %FOO%) or Ant ( ${env.FOO} ) can access these values.
[Correction by me.]
Those variables are available throughout the build so your Gradle build file can use them.

Related

manage Jenkins build status

I'd like to run batch using jenkins. And the status of build depends of number of files created in a specific folder. My question is how could I manage Jenkins build status depending of number of files created?
You can execute a shell script to count the files and return 1, if the count isn't expected.
Another way would be to use the Text-finder Plugin searching for a pattern in the console log.
Groovy Postbuild Plugin is another alternative:
buildUnstable() - sets the build result to UNSTABLE.
If you like to use the CLI you can use the following command:
java -jar jenkins-cli.jar -s http://...:8080/ set-build-result
Sets the result of the current build. Works only if invoked from within a build.

Supplying build info as qx.core.Environment entries

I have my qooxdoo project built and deployed by a CI server. Upon build, the server generates build info (version, VCS revision, CI build number, timestamp) that I would like to be passed to my qooxdoo app as qx.core.Environment keys.
At the moment, I have CI server generate a build.json file which is packaged together with the application, loaded at startup and converted to environment keys (by application code). This costs us an extra XHR.
On the other hand, I know that environment entries can be supplied during build, via config.json. Of course our build system can preprocess config.json to fill in environment entries, but I'm a bit skeptic of the idea of CI server fiddling with config.json. Is there any better solution? Is it possible to make generator script read environment entries from some auxiliary source?
I would write a #VERSION# tag into my script and at the end of the build process just search and replace this string in the compiled js file.
perl -i -p -e 's/#VERSION#/0.3.0/g' build/script/hello.js

Post-build arguments to batch script fails to convert build parameter

I'm using TFS 2013 and am building an Azure Cloud Service project that I want to package with Nuget so that I can publish to Octopus Deploy. I can't use octopack, because at the moment this is not supported. I'm trying to pass TFS parameters into a post-build batch script so that I can run nuget with -version parameters (which should change with each build).
The problem I'm having is that the batch script does not recognise the TFS build parameters. for example, in the script I want to pass an argument version $(TeamProject)-1.0.0$(Rev:.r), that would give the script the version to set in the package name.
The full nuget package call in the script is:
%nugetPath% push %packagePath%\Veedyo.%version%.nupkg
Passing this into the post-build script path works:
$/Application1/MAIN/Source/.NET/Application1.Package/package.cmd
This is because the source control path is translated into an actual path just after the build completes (and I can see the real path in the log).
However, the Post-build script arguments property in the build, doesn't convert this "$(TeamProject)"-1.0.0"$(Rev:.r)" to the desired value. this leads to an error executing the batch script:
Exception Message: TF270015: 'package.cmd' returned an unexpected exit code. Expected '0'; actual '1'. See the build logs for more details
So, does anyone have any idea how to convert add build parameter to the post-build script arguments property?
These macros are not available when you run the script. You can use one the the TF_BUILD environment variables listed here.
Probably, you are looking for TF_BUILD_BUILDNUMBER, or maybe you have to extract the data you are looking for; in this latter case Powershell can be simpler to use than cmd.exe interpreter.

Can the IAR command line tool "iarbuild" do a build all?

From the IAR command line, it's easy to build a particular configuration, and obviously, if I want to mimic the "build all" behavior I just run my own batch file with the configs I want.
How do I handle the case where I want to build all configs, but I don't know in advance what configurations are available?
Using Jenkins, for instance, if a developer adds a configuration in the IAR IDE, it won't be included in a build until the Jenkins scripts are manually updated. I just want Jenkins to build all the configurations without caring what they are called. In the IAR GUI for setting up batches, there is an option to rebuild all so there must be something somewhere. Thanks!
You can specify * as configuration name to build everything, like this:
c:\> iarbuild myproject.ewp -build *
One solution I've implemented years ago for this problem was to read the configuration names from the .ewp file and use them for the build.
Regards
Yves

Jenkins Post Build Task access jenkins environment variables like JOB_NAME

I want to get the job details in Post Build Task plugin and pass the details to the batch/ powershell for further processing.
I am not able to access the Jenkins environment variables like JOB_NAME, JOB_ID etc.
In Post Build Plugin task
Log text "BUILD SUCCESSFUL"
OPTION
Script Block:
run.bat $JOB_NAME-$JOB_ID
I need to pass the $JOB_NAME-$JOB_ID to the script.
Build Parameters are accesses as $Name in the Execute shell and post build section.
You can use
$JOB_NAME
$BUILD_NUMBER
for name of job and build number which is same as JOB_ID.
Also Set "Jenkins user build variables" to get more info regarding Environment variables.
Generally the sintax for accessing variables is the following:
${VARIABLE}
but in some cases, especially when you are trying to access variables using during the build, this sintax can be used:
${ENV, var="VARIABLE"}
That in my case is working also when you have a parameterized build.

Resources