Skip to content

Commit

Permalink
[releng] Add some guards on inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
pdulth committed Jun 13, 2023
1 parent 1efbd59 commit 9070072
Showing 1 changed file with 62 additions and 29 deletions.
91 changes: 62 additions & 29 deletions vars/deployer.groovy
Original file line number Diff line number Diff line change
@@ -1,40 +1,59 @@
def capellaNightlyProduct(String inputPath, String outputDirName) {
def outputPath = getFullCapellaProductPath(outputDirName)
def sshAccount = getSSHAccount()

sshagent (['projects-storage.eclipse.org-bot-ssh']) {
sh "ssh ${sshAccount} mkdir -p ${outputPath}"
sh "scp -rp ${inputPath} ${sshAccount}:${outputPath}"
}
if (isInvalid(outputDirName)) {
log.error("Deployment Error: ${outputDirName} is not recognised")
}
else {
def outputPath = getFullCapellaProductPath(outputDirName)
def sshAccount = getSSHAccount()

sshagent (['projects-storage.eclipse.org-bot-ssh']) {
sh "ssh ${sshAccount} mkdir -p ${outputPath}"
sh "scp -rp ${inputPath} ${sshAccount}:${outputPath}"
}
}
}

def capellaNightlyUpdateSite(String inputPath, String outputDirName) {
def outputPath = getFullCapellaUpdateSitePath(outputDirName)
def sshAccount = getSSHAccount()

sshagent (['projects-storage.eclipse.org-bot-ssh']) {
sh "ssh ${sshAccount} mkdir -p ${outputPath}"
sh "scp -rp ${inputPath} ${sshAccount}:${outputPath}"
}
if (isInvalid(outputDirName)) {
log.error("Deployment Error: ${outputDirName} is not recognised")
}
else {
def outputPath = getFullCapellaUpdateSitePath(outputDirName)
def sshAccount = getSSHAccount()

sshagent (['projects-storage.eclipse.org-bot-ssh']) {
sh "ssh ${sshAccount} mkdir -p ${outputPath}"
sh "scp -rp ${inputPath} ${sshAccount}:${outputPath}"
}
}
}

def cleanCapellaNightlyArtefacts(String dirName) {
def productPath = getFullCapellaProductPath(dirName)
def updateSitePath = getFullCapellaUpdateSitePath(dirName)
def sshAccount = getSSHAccount()

sshagent (['projects-storage.eclipse.org-bot-ssh']) {
sh "ssh ${sshAccount} rm -rf ${productPath}"
sh "ssh ${sshAccount} rm -rf ${updateSitePath}"
}
if (isInvalid(dirName)) {
log.error("Deployment Error: ${dirName} is not recognised")
}
else {

def productPath = getFullCapellaProductPath(dirName)
def updateSitePath = getFullCapellaUpdateSitePath(dirName)
def sshAccount = getSSHAccount()

sshagent (['projects-storage.eclipse.org-bot-ssh']) {
sh "ssh ${sshAccount} rm -rf ${productPath}"
sh "ssh ${sshAccount} rm -rf ${updateSitePath}"
}
}

}

def addonNightlyDropins(String inputPath, String outputDirName) {
def addonDirName = getAddonDirName()
def addonDirName = getAddonDirName()

if(addonDirName.isEmpty()) {
if(isInvalid(addonDirName)) {
log.error("Deployment Error: ${GIT_URL} repository is not recognised")

} else if (isInvalid(outputDirName)) {
log.error("Deployment Error: ${outputDirName} is not recognised")
}
else {
def outputPath = getFullAddonDropinsPath(addonDirName, outputDirName)
Expand All @@ -48,10 +67,13 @@ def addonNightlyDropins(String inputPath, String outputDirName) {
}

def addonNightlyUpdateSite(String inputPath, String outputDirName) {
def addonDirName = getAddonDirName()
def addonDirName = getAddonDirName()

if(addonDirName.isEmpty()) {
if(isInvalid(addonDirName)) {
log.error("Deployment Error: ${GIT_URL} repository is not recognised")

} else if (isInvalid(outputDirName)) {
log.error("Deployment Error: ${outputDirName} is not recognised")
}
else {
def outputPath = getFullAddonDropinsUpdateSitePath(addonDirName, outputDirName)
Expand All @@ -65,11 +87,15 @@ def addonNightlyUpdateSite(String inputPath, String outputDirName) {
}

def addonNightlyProduct(String inputPath, String outputDirName) {
def addonDirName = getAddonDirName()
def addonDirName = getAddonDirName()

if(addonDirName.isEmpty()) {
if(isInvalid(addonDirName)) {
log.error("Deployment Error: ${GIT_URL} repository is not recognised")

} else if (isInvalid(outputDirName)) {
log.error("Deployment Error: ${outputDirName} is not recognised")
}

else {
def outputPath = getFullAddonProductPath(addonDirName, outputDirName)
def sshAccount = getSSHAccount()
Expand All @@ -84,8 +110,11 @@ def addonNightlyProduct(String inputPath, String outputDirName) {
def cleanAddonNightlyArtefacts(String outputDirName) {
def addonDirName = getAddonDirName()

if(addonDirName.isEmpty()) {
if(isInvalid(addonDirName)) {
log.error("Deployment Error: ${GIT_URL} repository is not recognised")

} else if (isInvalid(outputDirName)) {
log.error("Deployment Error: ${outputDirName} is not recognised")
}
else {
def dropinPath = getFullAddonDropinsPath(addonDirName, outputDirName)
Expand Down Expand Up @@ -135,6 +164,10 @@ private def getAddonDirName() {
}
}

private def isInvalid(path) {
return path.isEmpty() || path.contains('..')
}

private def getSSHAccount() {
return "genie.capella@projects-storage.eclipse.org"
}
Expand Down

0 comments on commit 9070072

Please sign in to comment.