1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-03 15:02:35 +02:00

Merge branch 'master' into pr/removeMergeMethodFromConfigMerger

This commit is contained in:
Christopher Fenner 2018-09-10 13:32:01 +02:00 committed by GitHub
commit d07b64f477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 26 deletions

View File

@ -78,8 +78,8 @@ class ArtifactSetVersionTest extends BasePiperTest {
assertThat(jscr.shell, hasItem("mvn --file 'pom.xml' --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn versions:set -DnewVersion=1.2.3-20180101010203_testCommitId -DgenerateBackupPoms=false"))
assertThat(jscr.shell, hasItem('git add .'))
assertThat(jscr.shell, hasItem("git commit -m 'update version 1.2.3-20180101010203_testCommitId'"))
assertThat(jscr.shell, hasItems(containsString('git tag build_1.2.3-20180101010203_testCommitId'),
assertThat(jscr.shell, hasItems(containsString("git commit -m 'update version 1.2.3-20180101010203_testCommitId'"),
containsString('git tag build_1.2.3-20180101010203_testCommitId'),
containsString('git push myGitSshUrl build_1.2.3-20180101010203_testCommitId')))
}
@ -103,7 +103,7 @@ class ArtifactSetVersionTest extends BasePiperTest {
void testVersioningCustomGitUserAndEMail() {
jsr.step.artifactSetVersion(script: jsr.step, juStabGitUtils: gitUtils, buildTool: 'maven', gitSshUrl: 'myGitSshUrl', gitUserEMail: 'test@test.com', gitUserName: 'test')
assertThat(jscr.shell, hasItem("git -c user.email=\"test@test.com\" -c user.name=\"test\" commit -m 'update version 1.2.3-20180101010203_testCommitId'"))
assertThat(jscr.shell, hasItem(containsString("git -c user.email=\"test@test.com\" -c user.name=\"test\" commit -m 'update version 1.2.3-20180101010203_testCommitId'")))
}
@Test

View File

@ -1,12 +1,9 @@
import org.junit.Before
import org.junit.BeforeClass
import org.junit.ClassRule
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import org.junit.rules.TemporaryFolder
import org.yaml.snakeyaml.parser.ParserException
import hudson.AbortException
@ -23,9 +20,6 @@ public class MtaBuildTest extends BasePiperTest {
def toolMtaValidateCalled = false
def toolJavaValidateCalled = false
@ClassRule
public static TemporaryFolder tmp = new TemporaryFolder()
private ExpectedException thrown = new ExpectedException()
private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
private JenkinsShellCallRule jscr = new JenkinsShellCallRule(this)
@ -43,11 +37,6 @@ public class MtaBuildTest extends BasePiperTest {
.around(jder)
.around(jsr)
@BeforeClass
static void createTestFiles() {
}
@Before
void init() {

View File

@ -86,21 +86,23 @@ def call(Map parameters = [:], Closure body = null) {
sh 'git add .'
sshagent([config.gitSshKeyCredentialsId]) {
def gitUserMailConfig = ''
if (config.gitUserName && config.gitUserEMail)
gitUserMailConfig = "-c user.email=\"${config.gitUserEMail}\" -c user.name=\"${config.gitUserName}\""
def gitConfig = []
try {
sh "git ${gitUserMailConfig} commit -m 'update version ${newVersion}'"
} catch (e) {
error "[${STEP_NAME}]git commit failed: ${e}"
}
if(config.gitUserEMail) gitConfig.add("-c user.email=\"${config.gitUserEMail}\"")
if(config.gitUserName) gitConfig.add("-c user.name=\"${config.gitUserName}\"")
gitConfig = gitConfig.join(' ')
try {
sh """#!/bin/bash
git tag ${config.tagPrefix}${newVersion}
git push ${config.gitSshUrl} ${config.tagPrefix}${newVersion}"""
git ${gitConfig} commit -m 'update version ${newVersion}'
git tag ${config.tagPrefix}${newVersion}"""
config.gitCommitId = gitUtils.getGitCommitIdOrNull()
} catch (e) {
error "[${STEP_NAME}]git commit and tag failed: ${e}"
}
sshagent([config.gitSshKeyCredentialsId]) {
sh "git push ${config.gitSshUrl} ${config.tagPrefix}${newVersion}"
}
}