GIS-1621 - Use script prompting to obtain publishing info from user
This commit is contained in:
parent
ba79996557
commit
bc67f4dad1
5 changed files with 214 additions and 0 deletions
18
publish/ftp_query.groovy
Normal file
18
publish/ftp_query.groovy
Normal 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;
|
||||
129
publish/promptingpublish.groovy
Normal file
129
publish/promptingpublish.groovy
Normal 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
33
remoteaccess/ftp.groovy
Normal 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;
|
||||
28
remoteaccess/hostedftp.groovy
Normal file
28
remoteaccess/hostedftp.groovy
Normal 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;
|
||||
|
|
@ -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>()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue