You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-09-16 09:26:22 +02:00
TransportRequest: add UploadSOLMAN groovy step (#2688)
* TransportRequest: add UploadSOLMAN groovy step - groovy to go - use docker image in go - map credentials in go - generated yaml
This commit is contained in:
@@ -162,20 +162,32 @@ func transportRequestUploadSOLMANMetadata() config.StepData {
|
||||
Aliases: []config.Alias{{Name: "changeManagement/endpoint"}},
|
||||
},
|
||||
{
|
||||
Name: "username",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
|
||||
Type: "string",
|
||||
Mandatory: true,
|
||||
Aliases: []config.Alias{},
|
||||
Name: "username",
|
||||
ResourceRef: []config.ResourceReference{
|
||||
{
|
||||
Name: "uploadCredentialsId",
|
||||
Param: "username",
|
||||
Type: "secret",
|
||||
},
|
||||
},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
|
||||
Type: "string",
|
||||
Mandatory: true,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "password",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS"},
|
||||
Type: "string",
|
||||
Mandatory: true,
|
||||
Aliases: []config.Alias{},
|
||||
Name: "password",
|
||||
ResourceRef: []config.ResourceReference{
|
||||
{
|
||||
Name: "uploadCredentialsId",
|
||||
Param: "password",
|
||||
Type: "secret",
|
||||
},
|
||||
},
|
||||
Scope: []string{"PARAMETERS"},
|
||||
Type: "string",
|
||||
Mandatory: true,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "applicationId",
|
||||
@@ -266,6 +278,9 @@ func transportRequestUploadSOLMANMetadata() config.StepData {
|
||||
},
|
||||
},
|
||||
},
|
||||
Containers: []config.Container{
|
||||
{Name: "cmclient", Image: "ppiper/cm-client"},
|
||||
},
|
||||
Outputs: config.StepOutputs{
|
||||
Resources: []config.StepResources{
|
||||
{
|
||||
|
@@ -35,6 +35,10 @@ spec:
|
||||
- STAGES
|
||||
- STEPS
|
||||
- GENERAL
|
||||
resourceRef:
|
||||
- name: uploadCredentialsId
|
||||
type: secret
|
||||
param: username
|
||||
- name: password
|
||||
type: string
|
||||
mandatory: true
|
||||
@@ -42,6 +46,10 @@ spec:
|
||||
secret: true
|
||||
scope:
|
||||
- PARAMETERS
|
||||
resourceRef:
|
||||
- name: uploadCredentialsId
|
||||
type: secret
|
||||
param: password
|
||||
- name: applicationId
|
||||
type: string
|
||||
mandatory: true
|
||||
@@ -142,3 +150,6 @@ spec:
|
||||
params:
|
||||
- name: custom/changeDocumentId
|
||||
- name: custom/transportRequestId
|
||||
containers:
|
||||
- name: cmclient
|
||||
image: ppiper/cm-client
|
||||
|
@@ -181,6 +181,7 @@ public class CommonStepsTest extends BasePiperTest{
|
||||
'integrationArtifactGetServiceEndpoint', //implementing new golang pattern without fields
|
||||
'integrationArtifactDownload', //implementing new golang pattern without fields
|
||||
'integrationArtifactUpload', //implementing new golang pattern without fields
|
||||
'transportRequestUploadSOLMAN', //implementing new golang pattern without fields
|
||||
]
|
||||
|
||||
@Test
|
||||
|
64
test/groovy/TransportRequestUploadSOLMANTest.groovy
Normal file
64
test/groovy/TransportRequestUploadSOLMANTest.groovy
Normal file
@@ -0,0 +1,64 @@
|
||||
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.junit.Assert.assertThat
|
||||
import static org.hamcrest.Matchers.containsString
|
||||
import static org.hamcrest.Matchers.hasItem
|
||||
|
||||
public class TransportRequestUploadSOLMANTest 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,
|
||||
calledWithCredentials
|
||||
|
||||
helper.registerAllowedMethod(
|
||||
'piperExecuteBin',
|
||||
[Map, String, String, List],
|
||||
{
|
||||
params, stepName, metaData, creds ->
|
||||
calledWithParameters = params
|
||||
calledWithStepName = stepName
|
||||
calledWithMetadata = metaData
|
||||
calledWithCredentials = creds
|
||||
}
|
||||
)
|
||||
|
||||
stepRule.step.transportRequestUploadSOLMAN(script: nullScript, abc: 'CF')
|
||||
|
||||
assert calledWithParameters.size() == 2
|
||||
assert calledWithParameters.script == nullScript
|
||||
assert calledWithParameters.abc == 'CF'
|
||||
|
||||
assert calledWithStepName == 'transportRequestUploadSOLMAN'
|
||||
assert calledWithMetadata == 'metadata/transportRequestUploadSOLMAN.yaml'
|
||||
assert calledWithCredentials[0].size() == 3
|
||||
}
|
||||
}
|
17
vars/transportRequestUploadSOLMAN.groovy
Normal file
17
vars/transportRequestUploadSOLMAN.groovy
Normal 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/transportRequestUploadSOLMAN.yaml'
|
||||
|
||||
void call(Map parameters = [:]) {
|
||||
final script = checkScript(this, parameters) ?: this
|
||||
parameters = DownloadCacheUtils.injectDownloadCacheInParameters(script, parameters, BuildTool.MTA)
|
||||
|
||||
List credentials = [
|
||||
[type: 'usernamePassword', id: 'uploadCredentialsId', env: ['PIPER_username', 'PIPER_password']]
|
||||
]
|
||||
piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials)
|
||||
}
|
Reference in New Issue
Block a user