diff --git a/app/scripts/modules/core/src/domain/ITrigger.ts b/app/scripts/modules/core/src/domain/ITrigger.ts index ff144be01c1..85b9ecb4155 100644 --- a/app/scripts/modules/core/src/domain/ITrigger.ts +++ b/app/scripts/modules/core/src/domain/ITrigger.ts @@ -18,6 +18,12 @@ export interface IArtifactoryTrigger extends ITrigger { type: 'artifactory'; } +export interface INexusTrigger extends ITrigger { + nexusSearchName: string; + nexusRepository: string; + type: 'nexus'; +} + export interface IGitTrigger extends ITrigger { source: 'stash' | 'github' | 'bitbucket' | 'gitlab'; secret?: string; diff --git a/app/scripts/modules/core/src/pipeline/config/triggers/index.ts b/app/scripts/modules/core/src/pipeline/config/triggers/index.ts index 7c58329f4f1..6b173183a0c 100644 --- a/app/scripts/modules/core/src/pipeline/config/triggers/index.ts +++ b/app/scripts/modules/core/src/pipeline/config/triggers/index.ts @@ -1,6 +1,7 @@ 'use strict'; import './artifactory/artifactory.trigger'; +import './nexus/nexus.trigger'; import './concourse/concourse.trigger'; import './cron/cron.trigger'; import './git/git.trigger'; diff --git a/app/scripts/modules/core/src/pipeline/config/triggers/nexus/NexusTrigger.tsx b/app/scripts/modules/core/src/pipeline/config/triggers/nexus/NexusTrigger.tsx new file mode 100644 index 00000000000..d293f1ea91e --- /dev/null +++ b/app/scripts/modules/core/src/pipeline/config/triggers/nexus/NexusTrigger.tsx @@ -0,0 +1,35 @@ +import * as React from 'react'; + +import { FormikFormField, ReactSelectInput, useLatestPromise } from 'core/presentation'; + +import { NexusReaderService } from './nexusReader.service'; + +export function NexusTrigger() { + const fetchNames = useLatestPromise(() => NexusReaderService.getNexusNames(), []); + + const validationStatus = fetchNames.status === 'REJECTED' ? 'error' : null; + const validationMessage = + fetchNames.status === 'REJECTED' + ? `Error fetching nexus names: ${fetchNames.error.data.status} ${fetchNames.error.data.error}` + : null; + + return ( + ( + + )} + /> + ); +} diff --git a/app/scripts/modules/core/src/pipeline/config/triggers/nexus/nexus.trigger.ts b/app/scripts/modules/core/src/pipeline/config/triggers/nexus/nexus.trigger.ts new file mode 100644 index 00000000000..2b4f20443f4 --- /dev/null +++ b/app/scripts/modules/core/src/pipeline/config/triggers/nexus/nexus.trigger.ts @@ -0,0 +1,12 @@ +import { Registry } from 'core/registry'; +import { NexusTrigger } from './NexusTrigger'; +import { ArtifactTypePatterns, excludeAllTypesExcept } from 'core/artifact'; + +Registry.pipeline.registerTrigger({ + label: 'Nexus', + description: 'Executes the pipeline on a Nexus repo update', + key: 'nexus', + component: NexusTrigger, + validators: [], + excludedArtifactTypePatterns: excludeAllTypesExcept(ArtifactTypePatterns.MAVEN_FILE), +}); diff --git a/app/scripts/modules/core/src/pipeline/config/triggers/nexus/nexusReader.service.ts b/app/scripts/modules/core/src/pipeline/config/triggers/nexus/nexusReader.service.ts new file mode 100644 index 00000000000..50ef581323c --- /dev/null +++ b/app/scripts/modules/core/src/pipeline/config/triggers/nexus/nexusReader.service.ts @@ -0,0 +1,11 @@ +import { IPromise } from 'angular'; + +import { API } from 'core/api/ApiService'; + +export class NexusReaderService { + public static getNexusNames(): IPromise { + return API.one('nexus') + .one('names') + .get(); + } +} diff --git a/halconfig/settings.js b/halconfig/settings.js index de91f8552cd..e8435ce3ea9 100644 --- a/halconfig/settings.js +++ b/halconfig/settings.js @@ -224,6 +224,7 @@ window.spinnakerSettings = { pubsubProviders: ['google'], // TODO(joonlim): Add amazon once it is confirmed that amazon pub/sub works. triggerTypes: [ 'artifactory', + 'nexus', 'concourse', 'cron', 'docker', diff --git a/settings.js b/settings.js index 95c38ea8b9d..6c31e6912b9 100644 --- a/settings.js +++ b/settings.js @@ -214,6 +214,7 @@ window.spinnakerSettings = { searchVersion: 1, triggerTypes: [ 'artifactory', + 'nexus', 'concourse', 'cron', 'docker',