config.xml 3.17 KB
Newer Older
1 2
<?xml version='1.1' encoding='UTF-8'?>
<project>
3
  <actions/>
4
  <description>Hi365 APK Packager</description>
5
  <keepDependencies>false</keepDependencies>
6 7 8 9
  <properties>
    <com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty plugin="gitlab-plugin@1.5.12">
      <gitLabConnection>ylhealth</gitLabConnection>
    </com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty>
10 11 12 13 14 15 16 17 18 19 20 21 22 23
    <hudson.model.ParametersDefinitionProperty>
      <parameterDefinitions>
        <hudson.model.ChoiceParameterDefinition>
          <name>BUILD_BRANCH</name>
          <description>APK build env</description>
          <choices class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>develop</string>
              <string>master</string>
            </a>
          </choices>
        </hudson.model.ChoiceParameterDefinition>
      </parameterDefinitions>
    </hudson.model.ParametersDefinitionProperty>
24
  </properties>
25 26 27 28 29 30 31 32 33 34
  <scm class="hudson.plugins.git.GitSCM" plugin="git@3.12.0">
    <configVersion>2</configVersion>
    <userRemoteConfigs>
      <hudson.plugins.git.UserRemoteConfig>
        <url>https://cm.ylhealth.org/gitlab/YongYue/hi365-app.git</url>
        <credentialsId>3485e854-8389-40e8-8c86-b94e94e91904</credentialsId>
      </hudson.plugins.git.UserRemoteConfig>
    </userRemoteConfigs>
    <branches>
      <hudson.plugins.git.BranchSpec>
35
        <name>*/${BUILD_BRANCH}</name>
36 37 38 39 40 41
      </hudson.plugins.git.BranchSpec>
    </branches>
    <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
    <submoduleCfg class="list"/>
    <extensions/>
  </scm>
42
  <assignedNode>Mac_Node1</assignedNode>
43
  <canRoam>false</canRoam>
44 45 46 47 48
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers/>
  <concurrentBuild>false</concurrentBuild>
49 50
  <builders>
    <hudson.tasks.Shell>
51
      <command>project_path=$(pwd)
52 53 54 55

cd ${project_path}/android

app_version=$(grep &apos;version:&apos; pubspec.yaml | cut -d &apos; &apos; -f2)
56

57 58 59 60
current_date=$(date +&quot;%Y%m%d&quot;)

git_short_hash=$(git rev-parse --short HEAD)

61 62 63 64 65 66 67 68
# determine build type by git branch
if [ $BUILD_BRANCH == &quot;master&quot; ]
then
   	build_type=&quot;release&quot;
else
	build_type=&quot;debug&quot;
fi

69
output_path=&quot;${project_path}/build/app/outputs/apk/${build_type}&quot;
70

71
new_apk_name=&quot;Hi365_SIT_${current_date}-${git_short_hash}.apk&quot;
72

73
apk_path=&quot;${output_path}/${new_apk_name}&quot;
74

75 76 77

flutter build apk --${build_type}

78
# rename apk name
79 80 81 82
mv ${output_path}/app-${build_type}.apk ${apk_path}

# deploy
echo &quot;Deploy to APK repository&quot;
83
scp -i ~/jenkins/jenkins ${apk_path} appuploader@10.57.117.135:~/app/Hi365/${new_apk_name}
84
</command>
85 86
    </hudson.tasks.Shell>
  </builders>
87
  <publishers/>
88 89 90 91 92 93 94 95
  <buildWrappers>
    <hudson.plugins.ws__cleanup.PreBuildCleanup plugin="ws-cleanup@0.37">
      <deleteDirs>false</deleteDirs>
      <cleanupParameter></cleanupParameter>
      <externalDelete></externalDelete>
      <disableDeferredWipeout>false</disableDeferredWipeout>
    </hudson.plugins.ws__cleanup.PreBuildCleanup>
  </buildWrappers>
96
</project>