Skip to content

Commit

Permalink
Merge pull request #14 from metasfresh/gh2110-mf
Browse files Browse the repository at this point in the history
Gh2110 mf
  • Loading branch information
metas-ts authored Aug 8, 2017
2 parents 23a9eae + 6862a75 commit bada26d
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 57 deletions.
57 changes: 37 additions & 20 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// the "!#/usr/bin... is just to to help IDEs, GitHub diffs, etc properly detect the language and do syntax highlighting for you.
// thx to https://github.com/jenkinsci/pipeline-examples/blob/master/docs/BEST_PRACTICES.md

// note that we set a default version for this library in jenkins, so we don't have to specify it here
@Library('misc')
import de.metas.jenkins.MvnConf
import de.metas.jenkins.Misc

def boolean isRepoExists(String repoId)
{
withCredentials([usernameColonPassword(credentialsId: 'nexus_jenkins', variable: 'NEXUS_LOGIN')])
Expand Down Expand Up @@ -190,13 +195,12 @@ else
}

// set the version prefix, 1 for "master", 2 for "not-master" a.k.a. feature
final BUILD_VERSION_PREFIX = MF_UPSTREAM_BRANCH.equals('master') ? "1" : "2"
echo "Setting BUILD_VERSION_PREFIX=$BUILD_VERSION_PREFIX"
final MF_BUILD_VERSION_PREFIX = MF_UPSTREAM_BRANCH.equals('master') ? "1" : "2"
echo "Setting MF_BUILD_VERSION_PREFIX=$MF_BUILD_VERSION_PREFIX"

// the artifacts we build in this pipeline will have this version
// never incorporate params.MF_UPSTREAM_BUILDNO into the version anymore. Always go with the build number.
final BUILD_VERSION=BUILD_VERSION_PREFIX + "." + env.BUILD_NUMBER;
echo "Setting BUILD_VERSION=$BUILD_VERSION"
// the artifacts we build in this pipeline will have a version that ends with this string
final MF_BUILD_VERSION=MF_BUILD_VERSION_PREFIX + "-" + env.BUILD_NUMBER;
echo "Setting MF_BUILD_VERSION=$MF_BUILD_VERSION"

// metasfresh-task-repo is a constant (does not depent or the task/branch name) so that maven can find the credentials in our provided settings.xml file
final MF_MAVEN_REPO_ID = "metasfresh-task-repo";
Expand Down Expand Up @@ -232,20 +236,33 @@ MF_ARTIFACT_VERSIONS['metasfresh-webui'] = params.MF_METASFRESH_WEBUI_API_VERSIO
MF_ARTIFACT_VERSIONS['metasfresh-webui-frontend'] = params.MF_METASFRESH_WEBUI_FRONTEND_VERSION ?: "LATEST";

// these two are shown in jenkins, for each build
currentBuild.displayName="${MF_UPSTREAM_BRANCH} - build #${currentBuild.number} - artifact-version ${BUILD_VERSION}";
currentBuild.displayName="${MF_UPSTREAM_BRANCH} - build #${currentBuild.number} - artifact-version ${MF_BUILD_VERSION}";

timestamps
{
// https://github.com/metasfresh/metasfresh/issues/2110 make version/build infos more transparent
final String MF_RELEASE_VERSION = retrieveReleaseInfo(MF_UPSTREAM_BRANCH);
echo "Retrieved MF_RELEASE_VERSION=${MF_RELEASE_VERSION}"

// example version string: 5.20.2-23 with "5.20" == MF_RELEASE_VERSION
final String MF_VERSION="${MF_RELEASE_VERSION}.${MF_BUILD_VERSION}";
echo "set MF_VERSION=${MF_VERSION}";


// to build the client-exe on linux, we need 32bit libs!
node('agent && linux && libc6-i386')
{
configFileProvider([configFile(fileId: 'metasfresh-global-maven-settings', replaceTokens: true, variable: 'MAVEN_SETTINGS')])
{
// as of now, /base/src/main/resources/org/adempiere/version.properties contains "env.BUILD_VERSION", "env.MF_UPSTREAM_BRANCH" and others,
// as of now, /base/src/main/resources/org/adempiere/version.properties contains "env.MF_BUILD_VERSION", "env.MF_UPSTREAM_BRANCH" and others,
// which needs to be replaced when version.properties is dealt with by the ressources plugin, see https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
withEnv(["BUILD_VERSION=${BUILD_VERSION}", "MF_UPSTREAM_BRANCH=${MF_UPSTREAM_BRANCH}", "CHANGE_URL=${env.CHANGE_URL}", "BUILD_NUMBER=${env.BUILD_NUMBER}"])
withEnv([
"MF_RELEASE_VERSION=${MF_RELEASE_VERSION}",
"MF_BUILD_VERSION=${MF_BUILD_VERSION}",
"MF_UPSTREAM_BRANCH=${MF_UPSTREAM_BRANCH}",
"CHANGE_URL=${env.CHANGE_URL}",
"BUILD_NUMBER=${env.BUILD_NUMBER}"])
{
sh "echo \"testing 'witEnv' using shell: BUILD_VERSION=${BUILD_VERSION}\""
withMaven(jdk: 'java-8', maven: 'maven-3.3.9', mavenLocalRepo: '.repository')
{
stage('Set versions and build endcustomer-dist')
Expand Down Expand Up @@ -283,12 +300,12 @@ node('agent && linux && libc6-i386')
sh "mvn --settings $MAVEN_SETTINGS --file pom.xml --batch-mode ${MF_MAVEN_TASK_RESOLVE_PARAMS} ${metasfreshWebApiUpdatePropertyParam} versions:update-property"

// set the artifact version of everything below the endcustomer.mf15's parent pom.xml
sh "mvn --settings $MAVEN_SETTINGS --file pom.xml --batch-mode -DnewVersion=${BUILD_VERSION} -DallowSnapshots=false -DgenerateBackupPoms=true -DprocessDependencies=true -DprocessParent=true -DexcludeReactor=true ${MF_MAVEN_TASK_RESOLVE_PARAMS} versions:set"
sh "mvn --settings $MAVEN_SETTINGS --file pom.xml --batch-mode -DnewVersion=${MF_VERSION} -DallowSnapshots=false -DgenerateBackupPoms=true -DprocessDependencies=true -DprocessParent=true -DexcludeReactor=true ${MF_MAVEN_TASK_RESOLVE_PARAMS} versions:set"

// do the actual building and deployment
// about -Dmetasfresh.assembly.descriptor.version: the versions plugin can't update the version of our shared assembly descriptor de.metas.assemblies. Therefore we need to provide the version from outside via this property
// about -Dmaven.test.failure.ignore=true: continue if tests fail, because we want a full report.
sh "mvn --settings $MAVEN_SETTINGS --file pom.xml --batch-mode -Dmaven.test.failure.ignore=true -Dmetasfresh.assembly.descriptor.version=${BUILD_VERSION} ${MF_MAVEN_TASK_RESOLVE_PARAMS} ${MF_MAVEN_TASK_DEPLOY_PARAMS} clean deploy"
sh "mvn --settings $MAVEN_SETTINGS --file pom.xml --batch-mode -Dmaven.test.failure.ignore=true -Dmetasfresh.assembly.descriptor.version=${MF_VERSION} ${MF_MAVEN_TASK_RESOLVE_PARAMS} ${MF_MAVEN_TASK_DEPLOY_PARAMS} clean deploy"


// endcustomer.mf15 currently has no tests. Don't try to collect any, or a typical error migh look like this:
Expand All @@ -304,7 +321,7 @@ node('agent && linux && libc6-i386')
def mavenProps = readProperties file: 'dist/app.properties'

final MF_ARTIFACT_URLS = [:];
MF_ARTIFACT_URLS['metasfresh-dist'] = "https://repo.metasfresh.com/service/local/repositories/${MF_MAVEN_REPO_NAME}/content/de/metas/dist/metasfresh-orgs-dist/${BUILD_VERSION}/metasfresh-orgs-dist-${BUILD_VERSION}-dist.tar.gz";
MF_ARTIFACT_URLS['metasfresh-dist'] = "https://repo.metasfresh.com/service/local/repositories/${MF_MAVEN_REPO_NAME}/content/de/metas/dist/metasfresh-orgs-dist/${MF_VERSION}/metasfresh-orgs-dist-${MF_VERSION}-dist.tar.gz";
MF_ARTIFACT_URLS['metasfresh-webui'] = "https://repo.metasfresh.com/service/local/repositories/${MF_MAVEN_REPO_NAME}/content/de/metas/ui/web/metasfresh-webui-api/${mavenProps['metasfresh-webui-api.version']}/metasfresh-webui-api-${mavenProps['metasfresh-webui-api.version']}.jar";
MF_ARTIFACT_URLS['metasfresh-webui-frontend'] = "https://repo.metasfresh.com/service/local/repositories/${MF_MAVEN_REPO_NAME}/content/de/metas/ui/web/metasfresh-webui-frontend/${mavenProps['metasfresh-webui-frontend.version']}/metasfresh-webui-frontend-${mavenProps['metasfresh-webui-frontend.version']}.tar.gz";

Expand All @@ -315,7 +332,7 @@ node('agent && linux && libc6-i386')
currentBuild.description="""
<h3>Version infos</h3>
<ul>
<li>endcustomer.mf15: version <b>${BUILD_VERSION}</b></li>
<li>endcustomer.mf15: version <b>${MF_VERSION}</b></li>
<li>metasfresh-webui-API: version <b>${mavenProps['metasfresh-webui-api.version']}</b></li>
<li>metasfresh-webui-frontend: version <b>${mavenProps['metasfresh-webui-frontend.version']}</b></li>
<li>metasfresh-procurement-webui: <b>not part of this distribution</b></li>
Expand All @@ -325,8 +342,8 @@ node('agent && linux && libc6-i386')
<h3>Deployable artifacts</h3>
<ul>
<li><a href=\"${MF_ARTIFACT_URLS['metasfresh-dist']}\">dist-tar.gz</a></li>
<li><a href=\"https://repo.metasfresh.com/service/local/repositories/${MF_MAVEN_REPO_NAME}/content/de/metas/dist/metasfresh-orgs-dist/${BUILD_VERSION}/metasfresh-orgs-dist-${BUILD_VERSION}-sql-only.tar.gz\">sql-only-tar.gz</a></li>
<li><a href=\"https://repo.metasfresh.com/service/local/repositories/${MF_MAVEN_REPO_NAME}/content/de/metas/dist/metasfresh-orgs-swingui/${BUILD_VERSION}/metasfresh-orgs-swingui-${BUILD_VERSION}-client.zip\">client.zip</a></li>
<li><a href=\"https://repo.metasfresh.com/service/local/repositories/${MF_MAVEN_REPO_NAME}/content/de/metas/dist/metasfresh-orgs-dist/${MF_VERSION}/metasfresh-orgs-dist-${MF_VERSION}-sql-only.tar.gz\">sql-only-tar.gz</a></li>
<li><a href=\"https://repo.metasfresh.com/service/local/repositories/${MF_MAVEN_REPO_NAME}/content/de/metas/dist/metasfresh-orgs-swingui/${MF_VERSION}/metasfresh-orgs-swingui-${MF_VERSION}-client.zip\">client.zip</a></li>
<li><a href=\"${MF_ARTIFACT_URLS['metasfresh-webui']}\">metasfresh-webui-api.jar</a></li>
<li><a href=\"${MF_ARTIFACT_URLS['metasfresh-webui-frontend']}\">metasfresh-webui-frontend.tar.gz</a></li>
</ul>
Expand All @@ -345,7 +362,7 @@ node('agent && linux && libc6-i386')
""";
}
} // withMaven
} // withEnv(['"BUILD_VERSION=${BUILD_VERSION}"'])
} // withEnv
} // configFileProvider

// clean up the workspace after (successfull) builds
Expand Down Expand Up @@ -403,9 +420,9 @@ stage('Test SQL-Migration')
final sshTargetHost='mf15cloudit'; // we made sure the mf15cloudit can be resolved on every jenkins node labeled with 'linux'
final sshTargetUser='metasfresh'

downloadForDeployment('de.metas.dist', distArtifactId, BUILD_VERSION, packaging, classifier, sshTargetHost, sshTargetUser);
downloadForDeployment('de.metas.dist', distArtifactId, MF_VERSION, packaging, classifier, sshTargetHost, sshTargetUser);

final fileAndDirName="${distArtifactId}-${BUILD_VERSION}-${classifier}"
final fileAndDirName="${distArtifactId}-${MF_VERSION}-${classifier}"
final deployDir="/home/${sshTargetUser}/${fileAndDirName}-${MF_UPSTREAM_BRANCH}"

// Look Ma, I'm currying!!
Expand All @@ -414,7 +431,7 @@ stage('Test SQL-Migration')

final invokeRemoteInInstallDir = invokeRemote.curry(sshTargetHost, sshTargetUser, "${deployDir}/dist/install");
final VALIDATE_MIGRATION_TEMPLATE_DB='mf15_template';
final VALIDATE_MIGRATION_TEST_DB="tmp-metasfresh-dist-orgs-${MF_UPSTREAM_BRANCH}-${env.BUILD_NUMBER}-${BUILD_VERSION}"
final VALIDATE_MIGRATION_TEST_DB="tmp-metasfresh-dist-orgs-${MF_UPSTREAM_BRANCH}-${env.BUILD_NUMBER}-${MF_VERSION}"
.replaceAll('[^a-zA-Z0-9]', '_') // // postgresql is in a way is allergic to '-' and '.' and many other characters in in DB names
.toLowerCase(); // also, DB names are generally in lowercase

Expand Down
17 changes: 10 additions & 7 deletions base/src/main/resources/org/adempiere/version.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ buildNumber=${env.BUILD_NUMBER}
#
# Versions
#
# examples for BUILD_VERSION: "1-master-543", "2-FRESH-123-9842"
# note that there is a profile in de.metas.parent pom.xml that sets env.BUILD_VERSION to 3-LOCAL-BUILD-0 if there is no value set from the outside
MAIN_VERSION=5.20-${env.MF_UPSTREAM_BRANCH}-orgs-${env.BUILD_VERSION}
DATE_VERSION=2017-08-01
DB_VERSION=2017-08-01
IMPLEMENTATION_VENDOR=5.20-${env.MF_UPSTREAM_BRANCH}-orgs-${env.BUILD_VERSION}
IMPLEMENTATION_VERSION=5.20-${env.MF_UPSTREAM_BRANCH}-orgs-${env.BUILD_VERSION}
# note that
# * there is a profile in de.metas.parent pom.xml that sets env.BUILD_VERSION to 3-LOCAL-BUILD-0 if there is no value set from the outside
# * MF_RELEASE_VERSION is coming from https://github.com/metasfresh/metasfresh-release-info
# * unlike "BUILD_NUMBER", "MF_RELEASE_VERSION", "MF_BUILD_VERSION" and MF_UPSTREAM_BRANCH are not a jenkins standard, but provided by our particular jenkins files.
# That's why we use the "MF_" prefix.
MAIN_VERSION=${env.MF_RELEASE_VERSION}-${env.MF_UPSTREAM_BRANCH}-orgs-${env.MF_BUILD_VERSION}
DATE_VERSION=2017.08-01
IMPLEMENTATION_VENDOR=${env.MF_RELEASE_VERSION}-${env.MF_UPSTREAM_BRANCH}-orgs-${env.MF_BUILD_VERSION}
IMPLEMENTATION_VERSION=${env.MF_RELEASE_VERSION}-${env.MF_UPSTREAM_BRANCH}-orgs-${env.MF_BUILD_VERSION}


#
# Names
Expand Down
57 changes: 29 additions & 28 deletions dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@
<packaging>pom</packaging>

<properties>
<!--
<!--
Strip the version to make sure that the file names are the same of the target server, even if we roll out another version (e.g. IT vs UAT).
This is important because
This is important because
1. we rely on old files to be overwritten by new files
2. shell scripts are using certain jars in their class-paths
-->
<de.metas.endcustomer.stripVersion>true</de.metas.endcustomer.stripVersion>

<!--
The following *.version properties are changed by the build system via mvn versions:update-property.
See http://www.mojohaus.org/versions-maven-plugin/examples/update-properties.html
The following *.version properties are changed by the build system via mvn versions:update-property.
See http://www.mojohaus.org/versions-maven-plugin/examples/update-properties.html
and http://stackoverflow.com/questions/3628471/maven-versions-plugin-not-picking-up-properties-from-parent
-->
<!-- 1.0.0 is the version that is build and installed to our local repo bei eclipse or if we run maven from the command line -->
<metasfresh.version>1.0.0</metasfresh.version>
<metasfresh-webui-api.version>1.0.0</metasfresh-webui-api.version>
<metasfresh-webui-api.version>1.0.0</metasfresh-webui-api.version>

<!-- need to pick LATEST because there is now 1.0.0 version in our local repo. Because currently it's only build on jenkins. -->
<metasfresh-webui-frontend.version>LATEST</metasfresh-webui-frontend.version>
</properties>

<dependencies>

<!--
We used to just get many of the following deployables with the dependencies-plugin's copy goal, but there we need to give a version.
We used to just get many of the following deployables with the dependencies-plugin's copy goal, but there we need to give a version.
Ranges are not allowed.
Since we now work with a range, we now declare the dependencies here where ranges can be resolved, and can then further down use the copy-dependencies goal instead of the copy goal.
-->
Expand Down Expand Up @@ -96,9 +96,9 @@ Since we now work with a range, we now declare the dependencies here where range
<version>${metasfresh.version}</version>
</dependency>

<!--
<!--
gh #968 https://github.com/metasfresh/metasfresh/issues/968
We need to declare theses dependencies so that the version:update-property can update the *.version properties
We need to declare theses dependencies so that the version:update-property can update the *.version properties
Further down we will then copy these files to the dist folder using the copy-dependencies goal.
-->
<dependency>
Expand All @@ -114,7 +114,7 @@ Since we now work with a range, we now declare the dependencies here where range
<type>tar.gz</type>
</dependency>

<!--
<!--
SQL and jasper dependencies:
note: when adding new records, please roughly order them by alphabet.
-->
Expand Down Expand Up @@ -391,7 +391,7 @@ note: when adding new records, please roughly order them by alphabet.
<classifier>migration-postgres-sql</classifier>
<type>zip</type>
</dependency>

<!-- Elasticsearch -->
<dependency>
<groupId>de.metas.elasticsearch</groupId>
Expand All @@ -418,7 +418,7 @@ note: when adding new records, please roughly order them by alphabet.
<version>${spring-boot.version}</version>
<executions>
<execution>
<!--
<!--
Issue https://github.com/metasfresh/metasfresh/issues/2110:
Create build-info.properties and add them also to our distributable files
-->
Expand All @@ -430,10 +430,11 @@ note: when adding new records, please roughly order them by alphabet.
<configuration>
<outputFile>${project.build.directory}/build-info/build-info.properties</outputFile>
<additionalProperties>
<ciBuildNo>${env.BUILD_NUMBER}</ciBuildNo>
<ciBuildTag>${env.BUILD_TAG}</ciBuildTag>
<ciBuildUrl>${env.BUILD_URL}</ciBuildUrl>
<ciJobName>${env.JOB_NAME}</ciJobName>
<releaseVersion>${env.MF_RELEASE_VERSION}</releaseVersion>
<jenkinsBuildNo>${env.BUILD_NUMBER}</jenkinsBuildNo>
<jenkinsBuildTag>${env.BUILD_TAG}</jenkinsBuildTag>
<jenkinsBuildUrl>${env.BUILD_URL}</jenkinsBuildUrl>
<jenkinsJobName>${env.JOB_NAME}</jenkinsJobName>
</additionalProperties>
</configuration>
</execution>
Expand Down Expand Up @@ -468,8 +469,8 @@ note: when adding new records, please roughly order them by alphabet.
<executions>
<!-- Build deploy/reports -->
<execution>
<!--
First we explicitly extract everything that is *not* the jasper files from
<!--
First we explicitly extract everything that is *not* the jasper files from
de.metas.fresh.base or
metasfresh-orgs-base.
Among these files, we don't expect any name collisions.
Expand All @@ -491,8 +492,8 @@ note: when adding new records, please roughly order them by alphabet.
</configuration>
</execution>
<execution>
<!--
Then we extract the first the fresh-specific jasper files and finally the endcustomer-specific jasper files,
<!--
Then we extract the first the fresh-specific jasper files and finally the endcustomer-specific jasper files,
and we want them to overwrite the generic files if they have the same name.
-->
<id>unpack-jasper-fresh</id>
Expand Down Expand Up @@ -529,12 +530,12 @@ note: when adding new records, please roughly order them by alphabet.
</configuration>
</execution>

<!--
<!--
Build deploy/download folder: metasfresh server executable and client-zip
Note that we want to set the target file name, which is something, the copy goal offers, but not the copy-dependencies goal.
On the other hand, the copy goal does not work with version ranges
Fortunately, the client-zip has the same parent pom like this project and we can be sure that it will have the same version.
Therefore, we don't need to provide a version range and can thus use the copy goal.
Therefore, we don't need to provide a version range and can thus use the copy goal.
-->
<execution>
<id>copy-main-deployables</id>
Expand Down Expand Up @@ -566,11 +567,11 @@ note: when adding new records, please roughly order them by alphabet.
</configuration>
</execution>

<!--
<!--
Build deploy/download folder: metasfresh client zip, some camel ESB modules, etc.
We specified these artifacts as dependencies further up.
We specified these artifacts as dependencies further up.
Therefore they were already resolved and now we only need to grab 'em by the artifactid
without having to specify a particular version.
without having to specify a particular version.
-->
<execution>
<id>copy-metasfresh-download-jars</id>
Expand Down Expand Up @@ -639,7 +640,7 @@ note: when adding new records, please roughly order them by alphabet.
<type>zip</type>
<includeArtifactIds>de.metas.scripts.rollout</includeArtifactIds>
<excludeTransitive>true</excludeTransitive>
<!-- we assume that the rollout scripts were assembled with outputDirectory=install,
<!-- we assume that the rollout scripts were assembled with outputDirectory=install,
so the scripts shall end up in dist/install -->
<outputDirectory>${project.build.directory}/dist</outputDirectory>
</configuration>
Expand Down Expand Up @@ -710,7 +711,7 @@ note: when adding new records, please roughly order them by alphabet.
</plugin>

<plugin>
<!--
<!--
Here we combine a number of pre-fabricated metasfresh artifacts that might internally have different versions of the same libs.
Therefore our dependencyConvergence rule would fail. For that reason, we skip the enforcer.
It would be nice to skip just the dependencyConvergence rule, but i don't know how to do that.
Expand Down
2 changes: 1 addition & 1 deletion dist/src/main/assembly/dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<!-- https://github.com/metasfresh/metasfresh/issues/2110 -->
<fileSet>
<directory>${project.build.directory}/build-info</directory>
<outputDirectory></outputDirectory>
<outputDirectory>dist</outputDirectory>
</fileSet>

<!-- shell scripts -->
Expand Down
Loading

0 comments on commit bada26d

Please sign in to comment.