1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-09-16 09:26:22 +02:00

CTS Upload Groovy (#2970)

CTS Upload Groovy
- add step
This commit is contained in:
Roland Stengel
2021-07-08 16:37:39 +02:00
committed by GitHub
parent 805a8fd88f
commit e025c1d774
3 changed files with 83 additions and 0 deletions

View File

@@ -194,6 +194,7 @@ public class CommonStepsTest extends BasePiperTest{
'transportRequestUploadRFC', //implementing new golang pattern without fields
'writePipelineEnv', //implementing new golang pattern without fields
'readPipelineEnv', //implementing new golang pattern without fields
'transportRequestUploadCTS', //implementing new golang pattern without fields
]
@Test

View File

@@ -0,0 +1,65 @@
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import org.yaml.snakeyaml.parser.ParserException
import hudson.AbortException
import util.BasePiperTest
import util.JenkinsDockerExecuteRule
import util.JenkinsLoggingRule
import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.JenkinsStepRule
import util.JenkinsWriteFileRule
import util.Rules
import static org.hamcrest.Matchers.*
import static org.junit.Assert.assertThat
import static org.hamcrest.Matchers.hasEntry
public class TransportRequestUploadCTSTest extends BasePiperTest {
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
private JenkinsReadYamlRule readYamlRule = new JenkinsReadYamlRule(this)
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(stepRule)
.around(readYamlRule)
@Test
void testCallGoWrapper() {
def calledWithParameters,
calledWithStepName,
calledWithMetadata
List calledWithCredentials
helper.registerAllowedMethod(
'piperExecuteBin',
[Map, String, String, List],
{
params, stepName, metaData, creds ->
calledWithParameters = params
calledWithStepName = stepName
calledWithMetadata = metaData
calledWithCredentials = creds
}
)
stepRule.step.transportRequestUploadCTS(script: nullScript, abc: 'CF')
assertThat(calledWithParameters.size(), is(2))
assertThat(calledWithParameters.script, is(nullScript))
assertThat(calledWithParameters.abc, is('CF'))
assertThat(calledWithStepName, is('transportRequestUploadCTS'))
assertThat(calledWithMetadata, is('metadata/transportRequestUploadCTS.yaml'))
assertThat(calledWithCredentials[0].size(), is(3))
assertThat(calledWithCredentials[0], allOf(hasEntry('type','usernamePassword'), hasEntry('id','uploadCredentialsId'), hasEntry('env',['PIPER_username', 'PIPER_password'])))
}
}

View File

@@ -0,0 +1,17 @@
import com.sap.piper.BuildTool
import groovy.transform.Field
import static com.sap.piper.Prerequisites.checkScript
import com.sap.piper.DownloadCacheUtils
@Field String STEP_NAME = getClass().getName()
@Field String METADATA_FILE = 'metadata/transportRequestUploadCTS.yaml'
void call(Map parameters = [:]) {
final script = checkScript(this, parameters) ?: this
parameters = DownloadCacheUtils.injectDownloadCacheInParameters(script, parameters, BuildTool.NPM)
List credentials = [
[type: 'usernamePassword', id: 'uploadCredentialsId', env: ['PIPER_username', 'PIPER_password']]
]
piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials)
}