Domanda

I am using Jenkins, Ant , Flex and Java for my web application. Currently I update a build version file in Flex src and commit it before starting Jenkins build. I want to avoid this manual process and let script do this for me.

Contents of file:

Build=01_01_2013_10:43
Release=2.01

Question1: I want to update this file contents and compile my code and then commit this file back to svn. So that SVN has latest build version number.

How do I commit this changed file to SVN. Would be great if commit happens after successful build.

Question2: I want to send an email to all developers an hour before build starts. "Please commit your changes. Build will start in 1 hr." Can I set up a delay between email and (actual svn export + ant build).
or
Do I have to schedule 2 jobs an hour apart. One to send email and one to do build.

È stato utile?

Soluzione

You can use the subclipse svn ant integration to commit changed files to SVN including authentication:

<svnSetting
      svnkit="true"
      username="bingo"
      password="bongo"
      id="svn.settings"
  />
<svn refid="svn.settings">
    <commit file="your.file" />
</svn>

To get username and password to the build file you have different options. One would be to use a parametrized build, where you define user name and password as build parameters which can be evaluated in the build file.

      username="${parameter.svn.username}"
      password="${parameter.svn.password}"

A second option is using a the jenkins config file provider plugin. With this you can also use the parameters like for the parametrized build, but you import the credentials from the provided config file, e.g. a properties file can be imported via

<property file="config.file" />

Actually you can also use ant's exec task to execute your subversion commit the file.

For sending an e-mail one hour before actually building, you should setup two jobs, which are scheduled one hour apart. But I don't think this is good practice to notify before building, consider to build more often maybe even per commit to svn.

Altri suggerimenti

You can also use the Post build Task plugin (https://wiki.jenkins-ci.org/display/JENKINS/Post+build+task) to execute svn as a shell script (svn must be installed and authenticated from the shell once for the user that runs Jenkins).

Then the svn commit runs as a post build action. The plugin has an option (checkbox) to run the script only if the previous build/steps were successful.

The plugins is also mentioned here: Execute Shell Script after post build in Jenkins

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top