GIS-1621 - Use script prompting to obtain publishing info from user

This commit is contained in:
Dan Hawkins 2019-09-15 14:17:49 +01:00
commit 8858c55b23
5 changed files with 214 additions and 0 deletions

18
publish/ftp_query.groovy Normal file
View file

@ -0,0 +1,18 @@
ftpremote = load("${autobuilder.commonscripts()}/remoteaccess/ftp.groovy")
def getCustomerListFromFTP(FTPSiteInfo ftpsiteinfo) {
def List<String> customerfilenames = new ArrayList<String>()
def List<String> customers = new ArrayList<String>()
FTPClient ftpclient = ftpremote.createFTPClient(ftpsiteinfo)
customerfilenames = ftpclient.listNames()
for(customer in customerfilenames) {
def String converted = new String(customer.getBytes("ISO-8859-1"), "UTF-8")
customers.add(converted)
}
ftpclient.disconnect()
return customers
}
return this;

View file

@ -0,0 +1,129 @@
pipeline {
agent { label "${AGENT_LABEL}" }
stages {
stage('Initial setup') {
steps {
script {
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
}
}
}
stage('Clean folders') {
steps {
script {
cleanfolders = [
]
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
cleaner.clean(cleanfolders)
}
}
}
stage('Checkout release repo') {
steps {
script {
configurationhelper = autobuilder.configurationhelper()
SOURCEURL = RELEASE_REPO
SOURCEREVISION = "origin/master"
SOURCEDIR = "${WORKSPACE}/whole"
configurationhelper.gitCheckoutAndRegister(meta, 'whole', SOURCEURL, SOURCEREVISION, SOURCEDIR, '', 0, false)
}
}
}
stage('Identify customer to publish to') {
steps {
script {
hostedftb = load("${autobuilder.commonscripts()}/remoteaccess/hostedftp.groovy")
def List<String> customers = hostedftb.getCustomerList()
customer = input(
message: 'Please select customer to publish to',
ok: 'Ok',
parameters: [
choice(name: 'customer', choices: customers, description: 'Which customer?')
]
)
echo "Chosen customer is: ${customer}"
}
}
}
stage('Identify software release to publish') {
steps {
script {
gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
def List<String> releases = gh.gettaglist(SOURCEDIR)
release = input(
message: 'Please select the software version',
ok: 'Ok',
parameters: [
choice(name: 'release', choices: releases, description: 'Which release?')
]
)
echo "Chosen software version is: ${release}"
}
}
}
stage('Checkout release repo at selected software version') {
steps {
script {
SOURCEURL = RELEASE_REPO
SOURCEREVISION = "refs/tags/${release}"
SOURCEDIR = "${WORKSPACE}/whole"
configurationhelper.gitCheckoutAndRegister(meta, 'whole', SOURCEURL, SOURCEREVISION, SOURCEDIR, '', 0, false)
}
}
}
stage('Get release artifact meta') {
steps {
script {
def mfs = autobuilderscript.getmetafolderscript()
releasemeta = mfs.metafromfolder(SOURCEDIR)
}
}
}
stage('Publish components') {
steps {
script {
def publisher = load("${autobuilder.commonscripts()}/publish/do.groovy")
(summarystring, markunstable, unstablereason) = publisher.publishhierarchy(releasemeta, ITEMS_TO_PUBLISH, customer, release, MAX_META_DEPTH)
if (markunstable) {
env.unstablereason = unstablereason
currentBuild.result = 'UNSTABLE'
}
}
}
}
stage('Archiving artifacts') {
steps {
script {
def artifactlist = meta.generateartifacts()
archiveArtifacts "summary/**,${artifactlist}"
}
}
}
stage('Summarise') {
steps {
script {
echo "Summary:\n${summarystring}\n"
if (env.unstablereason) {
echo "Instability reason: ${env.unstablereason}"
}
}
}
}
}
post {
always {
echo 'Post-build'
}
failure {
echo 'Failed build'
}
unstable {
echo 'Unstable build'
}
success {
echo 'Succeeded build'
}
}
}

33
remoteaccess/ftp.groovy Normal file
View file

@ -0,0 +1,33 @@
@Grab(group='commons-net', module='commons-net', version='2.0')
import org.apache.commons.net.ftp.FTPClient
class FTPSiteInfo {
String url
String username
String password
String workingdirectory
FTPSiteInfo(String url, String username, String password, String workingdirectory) {
this.url = url
this.username = username
this.password = password
this.workingdirectory = workingdirectory
}
}
FTPSiteInfo createFTPSiteInfo(String url, String username, String password, String workingdirectory) {
FTPSiteInfo ftpsiteinfo = new FTPSiteInfo(url, username, password, workingdirectory)
return ftpsiteinfo
}
FTPClient createFTPClient(FTPSiteInfo ftpsiteinfo) {
FTPClient ftpclient = new FTPClient().with {
connect ftpsiteinfo.url
enterLocalPassiveMode()
login ftpsiteinfo.username, ftpsiteinfo.password
changeWorkingDirectory ftpsiteinfo.workingdirectory
}
return ftpclient
}
return this;

View file

@ -0,0 +1,28 @@
ftpremote = load("${autobuilder.commonscripts()}/remoteaccess/ftp.groovy")
FTPSiteInfo getHostedFTPSiteInfo() {
FTPSiteInfo hostedftpsiteinfo =
ftpremote.createFTPSiteInfo("ftp.hostedftp.com",
"ftp@globalinkjetsystems.com",
"ramshorn42",
"/Customers/")
return hostedftpsiteinfo
}
def getCustomerList() {
def List<String> customerfilenames = new ArrayList<String>()
def List<String> customers = new ArrayList<String>()
FTPSiteInfo ftpsiteinfo = getHostedFTPSiteInfo()
FTPClient ftpclient = ftpremote.createFTPClient(ftpsiteinfo)
customerfilenames = ftpclient.listNames()
for(customer in customerfilenames) {
def String converted = new String(customer.getBytes("ISO-8859-1"), "UTF-8")
customers.add(converted)
}
ftpclient.disconnect()
return customers
}
return this;

View file

@ -25,6 +25,12 @@ String getGitInfo(String workingSetRootPath) {
}
}
List<String> gettaglist(String workingSetRootPath) {
dir(workingSetRootPath) {
return clh.getCommandOutput('git tag --sort=-version:refname')
}
}
@NonCPS
def ArrayList<SparseCheckoutPath> sparsecheckoutconfig(ArrayList<String> paths) {
ArrayList<SparseCheckoutPath> sparsecheckoutpaths = new ArrayList<SparseCheckoutPath>()