Skip to content

Commit

Permalink
Merge branch 'master' into gh664webui
Browse files Browse the repository at this point in the history
Solved conflicts:
de.metas.swat/de.metas.swat.base/src/main/java/de/metas/ordercandidate/api/impl/OLCandBL.java

metasfresh/metasfresh-webui-api-legacy#664
  • Loading branch information
teosarca committed Feb 27, 2018
2 parents de93e8b + 14afa9a commit 4b8a30e
Show file tree
Hide file tree
Showing 3,438 changed files with 245,913 additions and 201,305 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

**/activemq-data/
**/data/
**/log/

# we have a java packages with de.metas.event.log.. so this doesn't work
# **/log/

de.metas.endcustomer.mf15/metasfresh.properties
/de.metas.endcustomer.mf15/de.metas.endcustomer.mf15.swingui/log/
Expand All @@ -29,3 +31,5 @@ de.metas.endcustomer.mf15/metasfresh.properties

# Ignore JRebel files because those contains file paths from local system
**/rebel.xml

de.metas.shipper.gateway.go/src/main/resources/application.properties
2 changes: 1 addition & 1 deletion .skip-archive-generated-artifacts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
This file diables automatic fingerprinting and archiving, because in particular the archiving takes up too much space on the jenkins master.
This file disables automatic fingerprinting and archiving, because in particular the archiving takes up too much space on the jenkins server.

Also see section "Maven Build Phases Reporters (since v2.0)" on https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Maven+Plugin
152 changes: 71 additions & 81 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ So if this is a "master" build, but it was invoked by a "feature-branch" build t
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: numberOfBuildsToKeepStr)) // keep the last $numberOfBuildsToKeepStr builds
]);

final String VERSIONS_PLUGIN = 'org.codehaus.mojo:versions-maven-plugin:2.5'

try
{
timestamps
Expand All @@ -53,7 +55,7 @@ node('agent && linux')
{
// create our config instance to be used further on
final MvnConf mvnConf = new MvnConf(
'de.metas.parent/pom.xml', // pomFile
'pom.xml', // pomFile
MAVEN_SETTINGS, // settingsFile
"mvn-${MF_UPSTREAM_BRANCH}", // mvnRepoName
'https://repo.metasfresh.com' // mvnRepoBaseURL
Expand All @@ -64,7 +66,7 @@ node('agent && linux')
// and therefore, the jenkins information would not be added to the build.properties info file.
withEnv(["MF_VERSION=${MF_VERSION}"])
{
withMaven(jdk: 'java-8', maven: 'maven-3.5.0', mavenLocalRepo: '.repository', mavenOpts: '-Xmx1536M')
withMaven(jdk: 'java-8', maven: 'maven-3.5.2', mavenLocalRepo: '.repository', mavenOpts: '-Xmx1536M')
{
// Note: we can't build the "main" and "esb" stuff in parallel, because the esb stuff depends on (at least!) de.metas.printing.api
stage('Set versions and build metasfresh')
Expand All @@ -84,22 +86,17 @@ node('agent && linux')
mvnUpdateParentPomVersion mvnConf

// set the artifact version of everything below ${mvnConf.pomFile}
// do not set versions for de.metas.endcustomer.mf15/pom.xml, because that one will be build in another node!
sh "mvn --settings ${mvnConf.settingsFile} --file ${mvnConf.pomFile} --batch-mode -DnewVersion=${MF_VERSION} -DallowSnapshots=false -DgenerateBackupPoms=true -DprocessDependencies=true -DprocessParent=true -DexcludeReactor=true -DprocessPlugins=true -Dincludes=\"de.metas*:*\" ${mvnConf.resolveParams} versions:set"

// deploy the de.metas.parent pom.xml to our repo. Other projects that are not build right now on this node will also need it. But don't build the modules that are declared in there
sh "mvn --settings ${mvnConf.settingsFile} --file ${mvnConf.pomFile} --batch-mode --non-recursive ${mvnConf.resolveParams} ${mvnConf.deployParam} clean deploy";

final MvnConf mvnReactorConf = mvnConf.withPomFile('de.metas.reactor/pom.xml');
echo "mvnReactorConf=${mvnReactorConf}"
// processAllModules=true: also update those modules that have a parent version range!
sh "mvn --settings ${mvnConf.settingsFile} --file ${mvnConf.pomFile} --batch-mode -DnewVersion=${MF_VERSION} -DprocessAllModules=true -Dincludes=\"de.metas*:*\" ${mvnConf.resolveParams} ${VERSIONS_PLUGIN}:set"

// update the versions of metas dependencies that are external to our reactor modules
sh "mvn --settings ${mvnReactorConf.settingsFile} --file ${mvnReactorConf.pomFile} --batch-mode -DallowSnapshots=false -DgenerateBackupPoms=true -DprocessDependencies=true -DprocessParent=true -DexcludeReactor=true -Dincludes=\"de.metas*:*\" ${mvnReactorConf.resolveParams} versions:use-latest-versions"
// Set the metasfresh.version property from [1,10.0.0] to our current build version
// From the documentation: "Set a property to a given version without any sanity checks"; that's what we want here..sanity is clearly overated
sh "mvn --settings ${mvnConf.settingsFile} --file ${mvnConf.pomFile} --batch-mode -Dproperty=metasfresh.version -DnewVersion=${MF_VERSION} ${VERSIONS_PLUGIN}:set-property"

// build and deploy
// 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
// maven.test.failure.ignore=true: continue if tests fail, because we want a full report.
sh "mvn --settings ${mvnReactorConf.settingsFile} --file ${mvnReactorConf.pomFile} --batch-mode -Dmaven.test.failure.ignore=true -Dmetasfresh.assembly.descriptor.version=${MF_VERSION} ${mvnReactorConf.resolveParams} ${mvnReactorConf.deployParam} clean deploy";
// 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
sh "mvn --settings ${mvnConf.settingsFile} --file ${mvnConf.pomFile} --batch-mode -Dmaven.test.failure.ignore=true -Dmetasfresh.assembly.descriptor.version=${MF_VERSION} ${mvnConf.resolveParams} ${mvnConf.deployParam} clean deploy"
} // if(params.MF_SKIP_TO_DIST)
}
stage('Build metasfresh docker image(s)')
Expand All @@ -111,13 +108,13 @@ node('agent && linux')
else
{
// now create and publish some docker images
createAndPublishDockerImage(
createAndPublishDockerImage_nexus(
'metasfresh-material-dispo-dev', // publishRepositoryName
'de.metas.material/dispo-service', // dockerModuleDir
MF_UPSTREAM_BRANCH, // dockerBranchName
MF_VERSION // dockerVersionSuffix
)
createAndPublishDockerImage(
createAndPublishDockerImage_nexus(
'metasfresh-report-dev', // dockerRepositoryName
'de.metas.report/report-service', // dockerModuleDir
MF_UPSTREAM_BRANCH, // dockerBranchName
Expand All @@ -126,34 +123,6 @@ node('agent && linux')
} // if(params.MF_SKIP_TO_DIST)
} // stage

stage('Set versions and build esb')
{
if(params.MF_SKIP_TO_DIST)
{
echo "params.MF_SKIP_TO_DIST=true so don't build metasfresh and esb jars and don't invoke downstream jobs"
}
else
{

// create our config instance to be used further on
final MvnConf mvnEsbConf = mvnConf.withPomFile('de.metas.esb/pom.xml');
echo "mvnEsbConf=${mvnEsbConf}"

mvnUpdateParentPomVersion mvnEsbConf

// set the artifact version of everything below de.metas.esb/pom.xml
sh "mvn --settings ${mvnEsbConf.settingsFile} --file ${mvnEsbConf.pomFile} --batch-mode -DnewVersion=${MF_VERSION} -DallowSnapshots=false -DgenerateBackupPoms=true -DprocessDependencies=true -DprocessParent=true -DexcludeReactor=true -Dincludes=\"de.metas*:*\" ${mvnEsbConf.resolveParams} versions:set"

// update the versions of metas dependencies that are external to the de.metas.esb reactor modules
sh "mvn --settings ${mvnEsbConf.settingsFile} --file ${mvnEsbConf.pomFile} --batch-mode -DallowSnapshots=false -DgenerateBackupPoms=true -DprocessDependencies=true -DprocessParent=true -DexcludeReactor=true -Dincludes=\"de.metas*:*\" ${mvnEsbConf.resolveParams} versions:use-latest-versions"

// build and deploy
// 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
// maven.test.failure.ignore=true: see metasfresh stage
sh "mvn --settings ${mvnEsbConf.settingsFile} --file ${mvnEsbConf.pomFile} --batch-mode -Dmaven.test.failure.ignore=true -Dmetasfresh.assembly.descriptor.version=${MF_VERSION} ${mvnEsbConf.resolveParams} ${mvnEsbConf.deployParam} clean deploy"
} // if(params.MF_SKIP_TO_DIST)
} // stage

if(!params.MF_SKIP_TO_DIST)
{
final MvnConf mvnJacocoConf = mvnConf.withPomFile('pom_for_jacoco_aggregate_coverage_report.xml');
Expand Down Expand Up @@ -218,8 +187,8 @@ stage('Invoke downstream jobs')
MF_UPSTREAM_BRANCH,
MF_ARTIFACT_VERSIONS['metasfresh-parent'],
MF_VERSION,
true,
'metasfresh-webui'); // wait=true
true, // wait=true
'metasfresh-webui');
MF_ARTIFACT_VERSIONS['metasfresh-webui'] = webuiDownStreamJobMap.MF_VERSION;
},
metasfresh_procurement_webui: {
Expand All @@ -229,9 +198,20 @@ stage('Invoke downstream jobs')
MF_UPSTREAM_BRANCH,
MF_ARTIFACT_VERSIONS['metasfresh-parent'],
MF_VERSION,
true,
'metasfresh-procurement-webui'); // wait=true
true, // wait=true
'metasfresh-procurement-webui');
MF_ARTIFACT_VERSIONS['metasfresh-procurement-webui'] = procurementWebuiDownStreamJobMap.MF_VERSION;
},
metasfresh_esb_camel: {
// yup, metasfresh-procurement-webui does share *some* code with this repo
final esbCamelDownStreamJobMap = invokeDownStreamJobs(
env.BUILD_NUMBER,
MF_UPSTREAM_BRANCH,
MF_ARTIFACT_VERSIONS['metasfresh-parent'],
MF_VERSION,
true, // wait=true
'metasfresh-esb-camel');
MF_ARTIFACT_VERSIONS['metasfresh-esb-camel'] = esbCamelDownStreamJobMap.MF_VERSION;
}
);

Expand Down Expand Up @@ -269,11 +249,6 @@ stage('Invoke downstream jobs')
parameters: distJobParameters,
wait: true
},
metasfresh_dist_orgs: {
build job: misc.getEffectiveDownStreamJobName('metasfresh-dist-orgs', MF_UPSTREAM_BRANCH),
parameters: distJobParameters,
wait: true
},
zapier: {
invokeZapier(env.BUILD_NUMBER, // upstreamBuildNo
MF_UPSTREAM_BRANCH, // upstreamBranch
Expand Down Expand Up @@ -308,7 +283,10 @@ stage('Invoke downstream jobs')
*/
void collectTestResultsAndReportCoverage()
{
junit '**/target/surefire-reports/*.xml'
// after upgrading the "Pipeline Maven Integration Plugin" from 0.7 to 3.1.0, collecting the tests is now done by that plugin.
// comment it out to avoid all tests being counted twice
// junit '**/target/surefire-reports/*.xml'

jacoco exclusionPattern: '**/src/main/java-gen' // collect coverage results for jenkins
}

Expand Down Expand Up @@ -373,39 +351,51 @@ void invokeZapier(
// note: even with "skiptodist=true we do this, because we still want to make the notifcations

echo "Going to notify external systems via zapier webhook"
withCredentials([string(credentialsId: 'zapier-metasfresh-build-notification-webhook', variable: 'zapier_WEBHOOK_SECRET')])
{
// the zapier secret contains a trailing slash and one that is somewhere in the middle.
final zapierUrl = "https://hooks.zapier.com/hooks/catch/${zapier_WEBHOOK_SECRET}"

//input id: 'Zapier-input-ok', message: 'Were the external donstream builds OK?'
final def hook = registerWebhook()
echo "Waiting for POST to ${hook.getURL()}"

/* we need to make sure we know "our own" MF_METASFRESH_VERSION, also if we were called by e.g. metasfresh-webui-api or metasfresh-webui--frontend */
final jsonPayload = """{
\"MF_UPSTREAM_BUILDNO\":\"${upstreamBuildNo}\",
\"MF_UPSTREAM_BRANCH\":\"${upstreamBranch}\",
\"MF_METASFRESH_VERSION\":\"${metasfreshVersion}\",
\"MF_METASFRESH_PROCUREMENT_WEBUI_VERSION\":\"${metasfreshProcurementWebuiVersion}\",
\"MF_METASFRESH_WEBUI_API_VERSION\":\"${metasfreshWebuiApiVersion}\",
\"MF_METASFRESH_WEBUI_FRONTEND_VERSION\":\"${metasfreshWebuiFrontendVersion}\",
\"MF_WEBHOOK_CALLBACK_URL\":\"${hook.getURL()}\"
}"""

final jsonPayload = """{
\"MF_UPSTREAM_BUILDNO\":\"${upstreamBuildNo}\",
\"MF_UPSTREAM_BRANCH\":\"${upstreamBranch}\",
\"MF_METASFRESH_VERSION\":\"${metasfreshVersion}\",
\"MF_METASFRESH_PROCUREMENT_WEBUI_VERSION\":\"${metasfreshProcurementWebuiVersion}\",
\"MF_METASFRESH_WEBUI_API_VERSION\":\"${metasfreshWebuiApiVersion}\",
\"MF_METASFRESH_WEBUI_FRONTEND_VERSION\":\"${metasfreshWebuiFrontendVersion}\",
\"MF_WEBHOOK_CALLBACK_URL\":\"${hook.getURL()}\"
}"""

// invoke zapier to trigger external jobs
nodeIfNeeded('linux')
{
sh "curl -X POST -d \'${jsonPayload}\' ${zapierUrl}";
sh "curl -X POST -d \'${jsonPayload}\' ${createZapierUrl()}";
}
waitForWebhookCall(hook);
}

echo "Wait 30 minutes for the zapier-triggered downstream jobs to succeed or fail"
timeout(time: 30, unit: 'MINUTES')
{
final def message = waitForWebhook hook // to stop and wait, for someone to do e.g. curl -X POST -d 'OK' <hook-URL>
if(message != 'OK')
{
error "An external job that was invoked by zapier failed; message=${message}; hook-URL=${hook.getURL()}"
}
}
} // withCredentials
String createZapierUrl()
{
withCredentials([string(credentialsId: 'zapier-metasfresh-build-notification-webhook', variable: 'zapier_WEBHOOK_SECRET')])
{
// the zapier secret contains a trailing slash and another slash that is somewhere in the middle.
return "https://hooks.zapier.com/hooks/catch/${zapier_WEBHOOK_SECRET}"
}
}

void waitForWebhookCall(final def hook)
{
echo "Wait 30 minutes for the zapier-triggered downstream jobs to succeed or fail"
timeout(time: 30, unit: 'MINUTES')
{
// stop and wait, for someone to do e.g. curl -X POST -d 'OK' <hook-URL>
final def message = waitForWebhook hook ?: '<webhook returned NULL>'
if(message.trim() == 'OK')
{
echo "The external jobs that were invoked by zapier succeeeded; message='${message}'; hook-URL=${hook.getURL()}"
}
else
{
error "An external job that was invoked by zapier failed; message='${message}'; hook-URL=${hook.getURL()}"
}
}
}
Loading

0 comments on commit 4b8a30e

Please sign in to comment.