2017-08-10 52 views
0

我們有一個項目存儲在BitBucket中。我們使用詹金斯從到位桶拉,運行/xenv/Maven/X/3.2.5/bin/mvn -f $WORKSPACE/feeds/project -s $WORKSPACE/feeds/project/settings.xml -e clean package -Dmaven.test.skip=true其次是這樣的:Maven在複製資源時跳過文件

export SVNMESSAGE=Commit msg 

chmod 755 $WORKSPACE/feeds/project/packageRelease.sh 

$WORKSPACE/feeds/project/packageRelease.sh NO 

packageRelase.sh負責最終推動JAR和其他所需的東西SVN部署在一個ZIP的形式。它看起來像這樣:

########################### 
# Variables Declarations� 
########################### 

export TMPDIR=TmpDir 

# SVN location where we will check the newly created zip 
export SVNPKGDIR=... 

# SVN location where we will create a release tag directory 
export SVNRELEASEDIRBASE=... 

# Name of the release tag directory to create 
export SVNRELEASEDIRNAME=Project_$(date +%Y%m%d) 


# Credentials for SVN checkins 
echo "SVN user" $SVNUSER 

######################### 
#Parse Arguments passed 
######################### 

BuildOnly="NO" 

if [ "$1" == "YES" ] 
    then 
    BuildOnly="YES" 
fi 

echo "Shell parameter value= $1" 
echo "BuildOnly value is set to : $BuildOnly" 

############################# 
### Check BuildOnly State ### 
############################# 

if [ ${BuildOnly} == "YES" ] 
    then 
    echo 
    echo "Build Only variable is set to ${BuildOnly} ; exiting program." 
    exit 0 
fi 

set -x 

############################## 
# Create the package directory 
############################## 

rm -fR ${TMPDIR} 
if [[ $? -ne 0 ]] 
then 
echo error removing existing ${TMPDIR} dir 
exit 2 
fi 

mkdir ${TMPDIR} 

if [[ $? -ne 0 ]] 
then 
echo error creating ${TMPDIR} dir 
exit 3 
fi 

################################ 
# Checkout svn package directory 
################################ 
svn checkout ${SVNPKGDIR}/send ${TMPDIR}/send --username ${SVNUSER} --password ${SVNPASSWORD} 

if [[ $? -ne 0 ]] 
then 
echo cannot checkout from svn RLM package directory ${SVNPKGDIR}/send 
exit 9 
fi 

################################### 
# Copy new zip to package directory 
################################### 

echo "copy $WORKSPACE/feeds/apamafeeds/ApamaFeeds.zip ${TMPDIR}/send" 
cp $WORKSPACE/feeds/apamafeeds/ApamaFeeds.zip ${TMPDIR}/send 

ls ${TMPDIR}/send 

if [[ $? -ne 0 ]] 
then 
echo cannot copy zip into RLM package directory ${TMPDIR}/send 
exit 10 
fi 

############################################### 
# Check into SVN package directory 
############################################### 
svn add ${TMPDIR}/send/* --force --username ${SVNUSER} --password ${SVNPASSWORD} 
svn ci --username ${SVNUSER} --password ${SVNPASSWORD} -m "${SVNMESSAGE}" ${TMPDIR}/send 

if [[ $? -ne 0 ]] 
then 
echo cannot checkin new zip to package directory. Working dir ${TMPDIR}/send 
exit 11 
fi 

############################################################ 
# Create a new tag Release directory in svn for this release 
############################################################ 
svn delete --username ${SVNUSER} --password ${SVNPASSWORD} -m "${SVNMESSAGE}" ${SVNRELEASEDIRBASE}/${SVNRELEASEDIRNAME} 
svn cp --username ${SVNUSER} --password ${SVNPASSWORD} -m "${SVNMESSAGE}" ${SVNPKGDIR} ${SVNRELEASEDIRBASE}/${SVNRELEASEDIRNAME} 


if [[ $? -ne 0 ]] 
then 
    echo cannot create tag release directory. From ${SVNPKGDIR} to ${SVNRELEASEDIRBASE}/${SVNRELEASEDIRNAME} 
    exit 15 
else 
    echo Tag release directory created. From ${SVNPKGDIR} to ${SVNRELEASEDIRBASE}/${SVNRELEASEDIRNAME} 
    exit 0 
fi 

的ZIP應包含多個.SH文件,SQL文件,一個JAR,一個config文件夾和數據文件夾。問題是它省略了所有的SQL文件。該SQL文件住在一個目錄下的文件.SH下src/main/scripts和目錄在pom.xml明確提到:

<plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-resources-plugin</artifactId> 
       <version>2.7</version> 
       <executions> 
        <execution> 
         <id>copy-resources</id> 
         <!-- here the phase you need --> 
         <phase>package</phase> 
         <goals> 
          <goal>copy-resources</goal> 
         </goals> 
         <configuration> 
          <outputDirectory>${basedir}/target/config</outputDirectory> 
          <resources> 
           <resource> 
            <directory>src/main/resources</directory> 
            <filtering>true</filtering> 
           </resource> 
          </resources> 
         </configuration> 
        </execution> 
        <execution> 
         <id>copy-scripts</id> 
         <phase>package</phase> 
         <goals> 
          <goal>copy-resources</goal> 
         </goals> 
         <configuration> 
          <outputDirectory>${basedir}/target/scripts</outputDirectory> 
          <resources> 
           <resource> 
            <directory>src/main/scripts</directory> 
            <filtering>true</filtering> 
           </resource> 
          </resources> 
         </configuration> 
        </execution> 
        <execution> 
         <id>copy-data</id> 
         <phase>package</phase> 
         <goals> 
          <goal>copy-resources</goal> 
         </goals> 
         <configuration> 
          <outputDirectory>${basedir}/target/data</outputDirectory> 
          <resources> 
           <resource> 
            <directory>src/main/data</directory> 
            <filtering>true</filtering> 
           </resource> 
          </resources> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 

爲什麼這些SQL文件(這肯定是在GIT中的scripts目錄),不使它到SVN,但.sh文件是?

+0

猜測:嘗試將您的'資源'執行放入'prepare-package'階段而不是'package'。我懷疑你的一些執行是在jar已經創建之後運行的。 – Andrei

回答

0

這個問題實際上並不在我上面列出的任何文件中。問題在於build.xml腳本。它有

<copy todir="${package.dir}/"> 
     <fileset dir="target/scripts"> 
      <include name="*.sh" /> 
     </fileset> 
    </copy> 

對於我而言,在<include>行應該看起來像<include name="*.*" />