Initial
commit
5fb81822eb
|
|
@ -0,0 +1,122 @@
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
parameters {
|
||||||
|
string(name: 'serviceName', defaultValue: 'my-service', description: 'Service Name')
|
||||||
|
string(name: 'interfaceName', defaultValue: 'B_IN_A_B', description: 'Interface Name')
|
||||||
|
string(name: 'interfaceType', defaultValue: 'Batch', description: 'Interface Type')
|
||||||
|
string(name: 'repositoryName', defaultValue: 'bwceApp', description: 'Repository Name')
|
||||||
|
string(name: 'repositoryProject', defaultValue: 'project', description: 'Repository Project')
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
MAVEN_SETTINGS = credentials('maven-settings') // Jenkins credential for settings.xml
|
||||||
|
GIT_PAT = credentials('git-pat') // Jenkins credential for PAT
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Checkout') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
checkout scm
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Prepare Environment') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
echo "Service Name: ${params.serviceName}"
|
||||||
|
echo "Interface Name: ${params.interfaceName}"
|
||||||
|
echo "Repository Name: ${params.repositoryName}"
|
||||||
|
echo "Interface Type: ${params.interfaceType}"
|
||||||
|
echo "Repository Project: ${params.repositoryProject}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Generate POM') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
writeFile file: 'pom.xml', text: '''<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.example</groupId>
|
||||||
|
<artifactId>example-project</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
</project>
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build with Maven') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
sh "mvn -s ${MAVEN_SETTINGS} -P BWCE archetype:generate -DartifactId=${params.serviceName} -Dk8sEnabled=N -DInterfaceType=${params.interfaceType} -DInterfaceNames=${params.interfaceName} -Dpackage='com.tibco.bw' -DgroupId='com.tibco.bw' -DarchetypeArtifactId=service-archetype -DarchetypeGroupId=onemdw.bwce -DarchetypeVersion=1.1.0-SNAPSHOT -DinteractiveMode=false"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Generate YAML File') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def yamlContent = """apiVersion: backstage.io/v1alpha1
|
||||||
|
kind: Component
|
||||||
|
metadata:
|
||||||
|
name: "${params.serviceName}"
|
||||||
|
title: "${params.serviceName}"
|
||||||
|
description: "${params.serviceName} description"
|
||||||
|
annotations:
|
||||||
|
dev.azure.com/project-repo: ${params.repositoryProject}/${params.repositoryName}
|
||||||
|
sonarqube.org/project-key: de.dlh.OIP.${params.repositoryProject}.${params.repositoryName}
|
||||||
|
backstage.io/linguist: https://dev.azure.com/lhg-oip/${params.repositoryProject}/_git/${params.repositoryName}
|
||||||
|
backstage.io/techdocs-ref: dir:.
|
||||||
|
links:
|
||||||
|
- url: "<solutionDesignDocumentUrl>"
|
||||||
|
title: Solution Design Document (SDD)
|
||||||
|
icon: docs
|
||||||
|
tags:
|
||||||
|
- bwce
|
||||||
|
spec:
|
||||||
|
type: service
|
||||||
|
lifecycle: experimental
|
||||||
|
owner: DH_TEAM_ONEMDW"""
|
||||||
|
|
||||||
|
writeFile file: "${params.serviceName}/catalog-info.yaml", text: yamlContent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Push to New Repository') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def repoUrl = "https://dev.azure.com/lhg-oip/${params.repositoryProject}/_git/${params.repositoryName}"
|
||||||
|
|
||||||
|
sh """
|
||||||
|
git config --global user.email "middleware.gdn.kafka@lhsystems.com"
|
||||||
|
git config --global user.name "OneMDW Team"
|
||||||
|
|
||||||
|
if [ -d "${params.repositoryName}" ]; then
|
||||||
|
rm -rf ${params.repositoryName}
|
||||||
|
fi
|
||||||
|
|
||||||
|
git clone https://${GIT_PAT}@dev.azure.com/lhg-oip/${params.repositoryProject}/_git/${params.repositoryName}
|
||||||
|
|
||||||
|
cp -r ${params.serviceName}/* ${params.repositoryName}/
|
||||||
|
|
||||||
|
cd ${params.repositoryName}
|
||||||
|
|
||||||
|
git checkout -b skeleton
|
||||||
|
git add .
|
||||||
|
git commit -m "Initial commit on skeleton branch"
|
||||||
|
git push origin skeleton
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue