@atomist/sample-sdm
Version:
Sample Atomist automation for software delivery
60 lines • 3.16 kB
JavaScript
;
/*
* Copyright © 2018 Atomist, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const sdm_1 = require("@atomist/sdm");
const EphemeralProgressLog_1 = require("@atomist/sdm/api-helper/log/EphemeralProgressLog");
const build = require("@atomist/sdm/dsl/buildDsl");
const MavenBuilder_1 = require("@atomist/sdm/internal/delivery/build/local/maven/MavenBuilder");
const machineFactory_1 = require("@atomist/sdm/machine/machineFactory");
const jvmPushTests_1 = require("@atomist/sdm/mapping/pushtest/jvm/jvmPushTests");
const fs = require("fs");
const demoEditors_1 = require("../pack/demo-editors/demoEditors");
/**
* Assemble a machine that only builds and verifies Java artifacts.
* @return {SoftwareDeliveryMachine}
*/
function artifactVerifyingMachine(configuration) {
const sdm = machineFactory_1.createSoftwareDeliveryMachine({
name: "Artifact verifying machine",
configuration,
}, sdm_1.whenPushSatisfies(jvmPushTests_1.IsMaven)
.itMeans("Push to Maven repo")
.setGoals(new sdm_1.Goals("Verify artifact", sdm_1.JustBuildGoal, sdm_1.ArtifactGoal)));
sdm
.addExtensionPacks(demoEditors_1.DemoEditors)
.addBuildRules(build.when(jvmPushTests_1.IsMaven)
.itMeans("build with Maven")
.set(new MavenBuilder_1.MavenBuilder(configuration.artifactStore, EphemeralProgressLog_1.createEphemeralProgressLog, configuration.projectLoader)))
.addArtifactListeners((ai) => __awaiter(this, void 0, void 0, function* () {
// Could invoke a security scanning tool etc.
const stat = fs.statSync(`${ai.deployableArtifact.cwd}/${ai.deployableArtifact.filename}`);
if (stat.size > 1000) {
return ai.addressChannels(`Artifact \`${ai.deployableArtifact.filename}\` is very big at ${stat.size} :weight_lifter:`);
}
}));
return sdm;
}
exports.artifactVerifyingMachine = artifactVerifyingMachine;
//# sourceMappingURL=artifactVerifyingMachine.js.map