Jenkins / Maven Release Plugin SVN - Credentials - jenkins

I have Jenkins Version 2.89.4 with the actual MavenReleasePlugin and SVN as repository. The SVN - Credentials set in the project configuration will not be used from the MavenReleasePlugin as I am aware.
Do I press in Jenkins the Build Release Button, I may enter user and password for SVN. This works fine, but it is work interactive.
How and where can I store these credentials in the background in Jenkins or any settings.xml ? so that I don't have to enter the credentials each time I am building a release.

You tell maven NOT to work in interactive mode using
mvn -B release:prepare
or
mvn --batch-mode release:prepare
Using batch mode with no other configuration will cause the Release Plugin to use default values for the release version, the SCM tag, and the next development version. These values can also be set from the command line. So you can set in the command line the "-username" and "-password" arguments.
Another option is to create a properties file that contains the version information for the project you would like to release. In this property file you can place the username and password.
Read more here and here.
Hope that helps!

Related

How can I automatically svn tag build artefacts with Jenkins?

I'm automating the following manual process with Jenkins:
Check out the trunk from svn
Build the code
Run tests
If the tests pass then tag the code and built artefacts
Steps 1-3 are working, but I need some help with tagging in step 4. There are some possible solutions that I've excluded:
The svn-tag plugin which has security issues and not developed
since 2015
The "tag this build" button which is a manual step and doesn't allow
me to select which files are tagged
Using svn command line tools on the slave, because I don't want to rely on them being install (and the same version as Jenkins), also I don't want to expose credentials to the build
Tools seem to be available for Git. Is there another way to do it for svn that I haven't thought of?
What about svn commandline?
Your could try to create a tag using shell :
svn copy http://svn/mywebsite/trunk http://svn/mywebsite/tags/2.2.1 -m "Release 2.2.1 - added new feature"
Source:
http://svnbook.red-bean.com/en/1.6/svn.branchmerge.tags.html
If it works, your step 4 could be a build step called : Execute Shell :
Just put your shell script in the text-area called command. You could use variables for your url, tag number, etc
Finally, you could create a jenkins plugin called svn command line tool to make life easier. Is not complex as many believe.

Jenkins Artifactory Plugin (gradle) doesn't read version from gradle.properties

Currently I try to configure Jenkins, so I can do my release builds automatically. It should change the version number from SNAPSHOT to a release version, and do all the SVN commit stuff. After this is done, it should switch it back to a new SNAPSHOT version and commit it, too. Before I switched from maven to gradle, the same plugin worked correctly.
I already created a gradle build, that works correctly. It is reading the version from the property "version" in the gradle.properties file. This version is the one that is used in the gradle build. It's also possible to run "artifactoryPublish" to publish the JAR to my artifactory.
The problem:
When I open the dialog "Artifactory Pro Release Staging" (http://imgur.com/T44BtQB) it is not filling the fields "Release version", "Next development version", and none of the other fields. If I fill the fields by hand, everything is working correctly. As well the version in gradle.properties is changed and checked in correctly.
How could I solve this problem?
Used Versions:
Jenkins Version 2.7.1
JFrog Artifactory 4.7.4 rev 40169 (free version)
Jenkins Artifactory Plugin 2.6.0 (https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Artifactory+Plugin+-+Release+Management)
Gradle 2.14.1
Thanks!
According to your description, when you access the "Artifactory Release Staging" page, the "Release version" and "Next development version" fields are empty. This might be because you did not define the property names for your version and next development version in your Jenkins job configuration.
Here's how you do it:
1. Open your gradle.properties file and find the name of your version property. For example, if your gradle.properties contains:
version=1.2-SNAPSHOT
then the name is "version".
2. Open your Jenkins job configuration, and put "version" in the "Release property" and "Next development properly" text fields. You should find them under the "Release Staging" configuration.
Now, the Artifactory Release Staging page should know where to take your versions from. This configuration is not required when using Artifactory Release Staging for Maven, because in Maven the version can be found at one place only - in the pom file.
Hope this helps
The way I see it, it seems your gradle.properties could not be committed with the rest of your files with SVN. Can you check this?
If it is committed and is effectively present with all the other source files when Jenkins executes the build job, it may be worth ensuring that the Jenkins build job is looking for the gradle.properties file at the right place. The Gradle plugin's default behaviour is to search for the gradle.properties file at the root of each project. If that's not where your gradle.properties file is, you may want to set the path manually. To do so, add the following under 'switches', in your Jenkins job:
-Dgradle.user.home=$HOME/.gradle
Let me know if this helps.
possibly this happens due to the below reason, while reading the properties
File permission - check the file group and owner in the work-space where your gradle.properties is located
2.(Not sure on details, it helped me in resolving) After updating the correct file owner group, removed the version property from jenkins artifactory release management section and triggered the build and once it is successful and included the version in jenkins artifactory release management section and triggered the build and it solved the problem.

Configure Jenkins to run Visual Studio bat file before Maven job

I have a Maven module that utilizes the NAR plugin to build some JNI libraries, and in Jenkins I have configured a Maven project to build this module. In order for these libs to be built, the Visual Studio bat file that sets up the path and other environment variables must be run. I have tried several different ways to get this bat file to execute before the Maven commands are called, and none of them have worked correctly. I know that Jenkins isolates all of the build process steps, so it can be difficult to get the environment set up, but I'm hoping someone has solved this particular issue. Here's what I've tried:
calling the bat file as a pre build step.
Using the EnvInject plugin to call the bat file, both as a pre build step and as a pre job step.
Setting the environment variables directly without calling the bat file using EnvInject.
calling the bat file from the mvn.bat file (this failed because it appears Jenkins will call Maven directly, without using the bat file).
As a workaround, I'm using the Freeform project type and setting the build steps to
call the bat file.
Directly call maven with appropriate parameters.
This works, but it's not as nice as using the Maven project type, ex. a failed unit test will fail the entire build instead of just sending a warning. Is there a way to configure this as a Maven project?

Getting CFBundleVersion from within Jenkins to use it as a variable, something like ${APP_VERSION}

What I'd like to do is to be able to add a tag to commits which Jenkins is building from. Right now I tag commits with the Jenkins build number but I want to also add in the app version as listed in the Info.plist CFBundleVersion in front of that.
What I want to know is, how I can grab that value using Jenkins or otherwise and be able to use that as a parameter/variable within Jenkins?
I've seen references to using plistbuddy to set this value so I would assume there's a way to use that to get the same value. Though how and how to get that to where I can use it in Jenkins I don't know.
For further clarification I am using Git Publisher in Jenkins to create a tag and push it with this format
jenkinsbuild-$BUILD_NUMBER
This results in a tag on the commit in git like this - jenkinsbuild-303
What I want, assuming my app is currently at version 3.5 is a tag that reads - jenkinsbuild-3.5-303
I managed to piece together a solution from the answer which #agy linked to. Here's what I did:
In the Build section for the Jenkins configuration, I added the following two lines to an 'Execute Shell' step after the Xcode step:
APP_VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "path to your plist")
echo APP_VERSION=$APP_VERSION > appversion.properties;
After that, I added an 'Inject Environment Variables' step (I think this is part of the EnvInject plugin), to which I added "appversion.properties" to the Properties File Path field.
After this is done, APP_VERSION is now available as an environment variable in subsequent shell command steps.

Creation of InstallAnywhere installer inside of Hudson CI

My company is trying to automate the creation of a nightly installer with Hudson. Our license to install anywhere is running on a separate server. We have an ANT build script set up to call the InstallAnywhere jar file which creates the installer automatically, and that works great when ran from the command prompt.
However when we try to run it inside of Hudson, Hudson is not able to connect to that license server. InstallAnywhere spits out The evaluation period has expired. Does anyone know what we can do to solve this issue?
I'm assuming it's a Hudson issue since our ANT script works fine when used outside of Hudson.
My best guess is that you need to set up some environment variables required by the InstallAnywhere process; I'm not very familiar with that product, but maybe it needs a home directory for the product, the location of the license file, the license key value, etc.
One easy way to debug this would be to check if Hudson is running under the same user that you are using to run the Ant script from the command line, then check the environment settings for the command line user if they are different.
Since I'm running Hudson as a service I had to use the "Default User" user. The solution was to copy the InstallAnywhere folder tree from "C:\Documents and Settings\MyUser" to "C:\Documents and Settings\Default User"
I just had the same issue, so I thought I would share my solution. You can also register the CI build user so you can continue using the automated user rather than switching it to your own user account: http://www.flexerasoftware.com/downloads/instructions/productlicensing/en/InstallAnywhereProductLicensing.pdf#page=15
Set up a bat file to execute:
<PATH_TO_IA>\build.exe -registerNodeLocked <PATH_TO_IA>\License.lic
Note, the License will be your mac address.lic, and you only have to do this once.
My bat was:
C:\Progra~2\Instal~2\build.exe -registerNodeLocked C:\Progra~2\Instal~2\[MAC].lic
Then I added a bat task to jenkins, and ran the job:
You should see something like:
Trying to checkout IAEE version=12.0
InstallAnywhere is successfully registered.

Resources