Skip to content

Commit

Permalink
Merge pull request #135 from stakater/pipeline-issues
Browse files Browse the repository at this point in the history
parametrize chart repository url in e2e tests
  • Loading branch information
kahootali authored Jan 8, 2019
2 parents 93368a2 + 1e5b6d5 commit 17f3f87
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 24 deletions.
10 changes: 6 additions & 4 deletions src/io/stakater/charts/ChartManager.groovy
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#!/usr/bin/groovy
package io.stakater.charts

def uploadToChartMuseum(String location, String chartName, String fileName) {
def uploadToChartMuseum(String location, String chartName, String fileName, String chartRepositoryURL) {
def chartMuseum = new io.stakater.charts.ChartMuseum()
chartMuseum.upload(location, chartName, fileName)
chartRepositoryURL = chartRepositoryURL + '/api/charts'
chartMuseum.upload(location, chartName, fileName, chartRepositoryURL)
}

def uploadToChartMuseum(String location, String chartName, String fileName, String cmUsername, String cmPassword) {
def uploadToChartMuseum(String location, String chartName, String fileName, String cmUsername, String cmPassword, String chartRepositoryURL) {
def chartMuseum = new io.stakater.charts.ChartMuseum()
chartMuseum.upload(location, chartName, fileName, cmUsername, cmPassword)
chartRepositoryURL = chartRepositoryURL + '/api/charts'
chartMuseum.upload(location, chartName, fileName, chartRepositoryURL, cmUsername, cmPassword)
}

def uploadToStakaterCharts(String packagedChart) {
Expand Down
8 changes: 0 additions & 8 deletions src/io/stakater/charts/ChartMuseum.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ def upload(String location, String chartName, String fileName, String cmUrl) {
"""
}

def upload(String location, String chartName, String fileName) {
upload(location, chartName, fileName, "http://chartmuseum.release/api/charts")
}

def upload(String location, String chartName, String fileName, String cmUrl, String cmUsername, String cmPassword) {
sh """
cd ${location}/${chartName}
Expand All @@ -30,8 +26,4 @@ def upload(String location, String chartName, String fileName, String cmUrl, Str
"""
}

def upload(String location, String chartName, String fileName, String cmUsername, String cmPassword) {
upload(location, chartName, fileName, "http://chartmuseum.release/api/charts", cmUsername, cmPassword)
}

return this
8 changes: 5 additions & 3 deletions vars/applyLandscaperManifests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

def call(body) {
def config = [:]
def common = new io.stakater.Common()

body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body()

def helmRepoName = config.helmRepoName ?: 'chartmuseum '
def helmRepoUrl = config.helmRepoUrl ?: 'http://chartmuseum'
def chartRepositoryURL = config.chartRepositoryURL ?: common.getEnvValue('CHART_REPOSITORY_URL')
def cluster = config.cluster ?: 'external'

def utils = new io.fabric8.Utils()
Expand Down Expand Up @@ -53,7 +55,7 @@ def call(body) {

sh "sleep 30s"

helm.addRepo(helmRepoName, helmRepoUrl)
helm.addRepo(helmRepoName, chartRepositoryURL)
}

stage('Dry Run Charts') {
Expand Down Expand Up @@ -149,7 +151,7 @@ def call(body) {

sh "sleep 30s"

helm.addRepo(helmRepoName, helmRepoUrl)
helm.addRepo(helmRepoName, chartRepositoryURL)
}

stage('Dry Run Charts') {
Expand Down
6 changes: 4 additions & 2 deletions vars/applyTempletizedLandscaperManifests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

def call(body) {
def config = [:]
def common = new io.stakater.Common()

body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body()

def helmRepoName = config.helmRepoName ?: 'chartmuseum '
def helmRepoUrl = config.helmRepoUrl ?: 'http://chartmuseum'
def chartRepositoryURL = config.chartRepositoryURL ?: common.getEnvValue('CHART_REPOSITORY_URL')

def utils = new io.fabric8.Utils()

Expand Down Expand Up @@ -67,7 +69,7 @@ def call(body) {

sh "sleep 30s"

helm.addRepo(helmRepoName, helmRepoUrl)
helm.addRepo(helmRepoName, chartRepositoryURL)
}

stage('Dry Run Charts') {
Expand Down
3 changes: 2 additions & 1 deletion vars/e2eTestStage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def call(Map parameters = [:], config) {
def chartVersion = parameters.get('chartVersion', '')
def repoUrl = parameters.get('repoUrl', '')
def repoBranch = parameters.get('repoBranch', '')
def testJob = build job: e2eJobName, parameters: [ [$class: 'StringParameterValue', name: 'chartName', value: chartName ], [$class: 'StringParameterValue', name: 'chartVersion', value: chartVersion ], [$class: 'StringParameterValue', name: 'repoUrl', value: repoUrl ], [$class: 'StringParameterValue', name: 'repoBranch', value: repoBranch ], [$class: 'StringParameterValue', name: 'performanceTestJobName', value: performanceTestJobName ], [$class: 'StringParameterValue', name: 'appName', value: appName ], [$class: 'StringParameterValue', name: 'mockAppsJobName', value: mockAppsJobName ], [$class: 'StringParameterValue', name: 'config', value: JsonOutput.toJson(config) ] ], propagate:false
def chartRepositoryURL = parameters.get('chartRepositoryURL', '')
def testJob = build job: e2eJobName, parameters: [ [$class: 'StringParameterValue', name: 'chartName', value: chartName ], [$class: 'StringParameterValue', name: 'chartVersion', value: chartVersion ], [$class: 'StringParameterValue', name: 'repoUrl', value: repoUrl ], [$class: 'StringParameterValue', name: 'repoBranch', value: repoBranch ], [$class: 'StringParameterValue', name: 'performanceTestJobName', value: performanceTestJobName ], [$class: 'StringParameterValue', name: 'appName', value: appName ], [$class: 'StringParameterValue', name: 'mockAppsJobName', value: mockAppsJobName ], [$class: 'StringParameterValue', name: 'chartRepositoryURL', value: chartRepositoryURL ], [$class: 'StringParameterValue', name: 'config', value: JsonOutput.toJson(config) ] ], propagate:false

String text = "<h2>Regression test</h2><a href=\"${testJob.getAbsoluteUrl()}\">${testJob.getProjectName()} ${testJob.getDisplayName()} - ${testJob.getResult()}</a>"
rtp(nullAction: '1', parserName: 'HTML', stableText: text, abortedAsStable: true, failedAsStable: true, unstableAsStable: true)
Expand Down
5 changes: 4 additions & 1 deletion vars/goBuildAndRelease.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def call(body) {
def docker = new io.stakater.containers.Docker()
def stakaterCommands = new io.stakater.StakaterCommands()
def slack = new io.stakater.notifications.Slack()

def chartRepositoryURL = config.chartRepositoryURL ?: common.getEnvValue('CHART_REPOSITORY_URL')

try {
stage('Download Dependencies') {
sh """
Expand Down Expand Up @@ -128,7 +131,7 @@ def call(body) {
stage('Chart: Upload') {
String cmUsername = common.getEnvValue('CHARTMUSEUM_USERNAME')
String cmPassword = common.getEnvValue('CHARTMUSEUM_PASSWORD')
chartManager.uploadToChartMuseum(chartDir, repoName.toLowerCase(), chartPackageName, cmUsername, cmPassword)
chartManager.uploadToChartMuseum(chartDir, repoName.toLowerCase(), chartPackageName, cmUsername, cmPassword, chartRepositoryURL)

def packagedChartLocation = chartDir + "/" + repoName.toLowerCase() + "/" + chartPackageName;
chartManager.uploadToStakaterCharts(packagedChartLocation)
Expand Down
4 changes: 3 additions & 1 deletion vars/goBuildViaGoReleaser.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def call(body) {
def docker = new io.stakater.containers.Docker()
def stakaterCommands = new io.stakater.StakaterCommands()
def slack = new io.stakater.notifications.Slack()
def chartRepositoryURL = config.chartRepositoryURL ?: common.getEnvValue('CHART_REPOSITORY_URL')

try {
stage('Download Dependencies') {
sh """
Expand Down Expand Up @@ -128,7 +130,7 @@ def call(body) {
stage('Chart: Upload') {
String cmUsername = common.getEnvValue('CHARTMUSEUM_USERNAME')
String cmPassword = common.getEnvValue('CHARTMUSEUM_PASSWORD')
chartManager.uploadToChartMuseum(chartDir, repoName.toLowerCase(), chartPackageName, cmUsername, cmPassword)
chartManager.uploadToChartMuseum(chartDir, repoName.toLowerCase(), chartPackageName, cmUsername, cmPassword, chartRepositoryURL)

def packagedChartLocation = chartDir + "/" + repoName.toLowerCase() + "/" + chartPackageName;
chartManager.uploadToStakaterCharts(packagedChartLocation)
Expand Down
3 changes: 2 additions & 1 deletion vars/prepareAndUploadChart.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def call(body) {
def utils = new io.fabric8.Utils()
def slack = new io.stakater.notifications.Slack()

def chartRepositoryURL = config.chartRepositoryURL ?: common.getEnvValue('CHART_REPOSITORY_URL')
def chartName = config.chartName
def isPublic = config.isPublic ?: false
def packageName
Expand All @@ -40,7 +41,7 @@ def call(body) {
stage("Upload Chart: ${chartName}") {
String cmUsername = common.getEnvValue('CHARTMUSEUM_USERNAME')
String cmPassword = common.getEnvValue('CHARTMUSEUM_PASSWORD')
chartManager.uploadToChartMuseum(WORKSPACE, chartName.toLowerCase(), packageName, cmUsername, cmPassword)
chartManager.uploadToChartMuseum(WORKSPACE, chartName.toLowerCase(), packageName, cmUsername, cmPassword, chartRepositoryURL)
if(isPublic){
def packagedChartLocation = WORKSPACE + "/" + chartName.toLowerCase() + "/" + packageName;
chartManager.uploadToStakaterCharts(packagedChartLocation)
Expand Down
4 changes: 2 additions & 2 deletions vars/releaseMavenApplication.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ def call(body) {

String cmUsername = common.getEnvValue('CHARTMUSEUM_USERNAME')
String cmPassword = common.getEnvValue('CHARTMUSEUM_PASSWORD')
chartManager.uploadToChartMuseum(chartDir, repoName.toLowerCase(), chartPackageName, cmUsername, cmPassword)
chartManager.uploadToChartMuseum(chartDir, repoName.toLowerCase(), chartPackageName, cmUsername, cmPassword, chartRepositoryURL)
}
stage('Run Synthetic/E2E Tests') {
echo "Running synthetic tests for Maven application: ${e2eTestJob}"
if (!e2eTestJob.equals("")){
e2eTestStage(appName: appName, e2eJobName: e2eTestJob, performanceTestJobName: performanceTestsJob, chartName: repoName.toLowerCase(), chartVersion: helmVersion, repoUrl: repoUrl, repoBranch: repoBranch, mockAppsJobName: mockAppsJobName, [
e2eTestStage(appName: appName, e2eJobName: e2eTestJob, performanceTestJobName: performanceTestsJob, chartName: repoName.toLowerCase(), chartVersion: helmVersion, repoUrl: repoUrl, repoBranch: repoBranch, chartRepositoryURL: chartRepositoryURL, mockAppsJobName: mockAppsJobName, [
microservice: [
name : repoName.toLowerCase(),
version: helmVersion
Expand Down
2 changes: 1 addition & 1 deletion vars/releaseNodeApplication.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def call(body) {

String cmUsername = common.getEnvValue('CHARTMUSEUM_USERNAME')
String cmPassword = common.getEnvValue('CHARTMUSEUM_PASSWORD')
chartManager.uploadToChartMuseum(chartDir, repoName.toLowerCase(), chartPackageName, cmUsername, cmPassword)
chartManager.uploadToChartMuseum(chartDir, repoName.toLowerCase(), chartPackageName, cmUsername, cmPassword, chartRepositoryURL)
}
stage('Run Synthetic/E2E Tests') {
echo "Running synthetic tests for Node application: ${e2eTestJob}"
Expand Down

0 comments on commit 17f3f87

Please sign in to comment.