From 01b03f0df3995bc62b079b7637285a905817a570 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Thu, 27 Sep 2018 16:15:49 +0200 Subject: [PATCH] [refactoring] Reduce number of sh calls --- test/groovy/ArtifactSetVersionTest.groovy | 4 ++-- vars/artifactSetVersion.groovy | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/test/groovy/ArtifactSetVersionTest.groovy b/test/groovy/ArtifactSetVersionTest.groovy index 3cc498447..82931b8d3 100644 --- a/test/groovy/ArtifactSetVersionTest.groovy +++ b/test/groovy/ArtifactSetVersionTest.groovy @@ -89,8 +89,8 @@ class ArtifactSetVersionTest extends BasePiperTest { assertEquals('testCommitId', jer.env.getGitCommitId()) 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, hasItems(containsString("git commit -m 'update version 1.2.3-20180101010203_testCommitId'"), + assertThat(jscr.shell, hasItems(containsString("git add ."), + 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'))) } diff --git a/vars/artifactSetVersion.groovy b/vars/artifactSetVersion.groovy index 43c3b7d6a..d7e77fa27 100644 --- a/vars/artifactSetVersion.groovy +++ b/vars/artifactSetVersion.groovy @@ -84,8 +84,6 @@ def call(Map parameters = [:], Closure body = null) { .withMandatoryProperty('gitSshUrl') .use() - sh 'git add .' - def gitConfig = [] if(config.gitUserEMail) gitConfig.add("-c user.email=\"${config.gitUserEMail}\"") @@ -94,6 +92,7 @@ def call(Map parameters = [:], Closure body = null) { try { sh """#!/bin/bash + git add . git ${gitConfig} commit -m 'update version ${newVersion}' git tag ${config.tagPrefix}${newVersion}""" config.gitCommitId = gitUtils.getGitCommitIdOrNull()