1

I was setting up jenkins to create war builds using git and maven . I have created a hook in bitbucket to invoke jenkins build also mentioned the branch name in jenkins to build in a specific branch . Issue is that whenever there is a new commit in any of the branches jenkins is building and redeploying the war file . What i need is , jenkins should abort the build if there are not change in git . Please help.

EDIT: I did tried in maven level using plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <archive>
            <forced>false</forced>
        </archive>
    </configuration>
</plugin>`

Still maven is building the war file if there are "No sources to compile."

jiaweizhang
  • 809
  • 1
  • 11
  • 28
Mohammed shebin
  • 479
  • 3
  • 11
  • 24

1 Answers1

0

When you configure BitBucket to call a jenkins job, that will call it on any push (regerdless of the branch)

Your jenkins job should be in charge of:

  • step 1: analyzing the json payload (which is, since July 2015, a "Fuller, more descriptive payload")
  • step 2: if the right branch is detected in the payload, trigger a second Jenkins job in charge of fetching the git repo and launching a build.
    For instance, you can use the BuildResultTrigger Plugin.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Looks like this is the only way . Thanks for the help. Some heavy work needed . Do you have any link that says how to parse the json payload ? – Mohammed shebin Nov 19 '15 at 10:40