• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2
3mvn org.walkmod.maven.plugins:walkmod-maven-plugin:apply -Dchains=pmd -Dproperties="configurationFile=ruleset.xml" -Dpath=src/main/java
4git diff > walkmod.patch
5
6if [ "$TRAVIS_PULL_REQUEST" = false ] ; then
7    echo 'Skipped build. This is not a pull request'
8    exit 0
9fi
10
11if [ -z "$TRAVIS_REPO_SLUG" ]
12then
13  echo "There is not TRAVIS_REPO_SLUG defined"
14  exit 1
15fi
16
17if [ -z "$TRAVIS_PULL_REQUEST_SHA" ]
18then
19  echo "There is not TRAVIS_PULL_REQUEST_SHA defined"
20  exit 1
21fi
22
23if [ -z "$OCTOPATCH_API_TOKEN" ] ; then
24    echo "There is not OCTOPATCH_API_TOKEN defined"
25    exit 1
26fi
27
28REQUEST="curl -X POST -H \"Content-Type: multipart/form-data\""
29FILES=$(find . -type f -name "*.patch")
30if [ -z "$FILES" ]
31then
32    echo "Perfect! There are not patch files"
33    exit 0
34fi
35
36for FILE in $FILES
37do
38  REQUEST+=" -F \"data=@$FILE\""
39done
40
41REQUEST+=" -H \"Authorization: $OCTOPATCH_API_TOKEN\" api.octopatch.io/api/pulls/$TRAVIS_REPO_SLUG/$TRAVIS_PULL_REQUEST/$TRAVIS_PULL_REQUEST_SHA"
42eval $REQUEST