Cleanup ssh and git functions
Change-Id: I5e9a1acab12e479d86321aa9822e6383a707d624
diff --git a/git-mirror-2way-pipeline.groovy b/git-mirror-2way-pipeline.groovy
index 0b7e023..e70e9e7 100644
--- a/git-mirror-2way-pipeline.groovy
+++ b/git-mirror-2way-pipeline.groovy
@@ -1,4 +1,5 @@
def common = new com.mirantis.mk.Common()
+def git = new com.mirantis.mk.Git()
stage("Mirror") {
node() {
try{
@@ -16,7 +17,7 @@
checkout changelog: true, poll: true,
scm: [$class: 'GitSCM', branches: pollBranches, doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CleanCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: CREDENTIALS_ID, url: SOURCE_URL]]]
- common.mirrorGit(SOURCE_URL, TARGET_URL, CREDENTIALS_ID, BRANCHES, true, true, false)
+ git.mirrorGit(SOURCE_URL, TARGET_URL, CREDENTIALS_ID, BRANCHES, true, true, false)
}
} catch (Throwable e) {
// If there was an error or exception thrown, the build failed
@@ -26,4 +27,4 @@
common.sendNotification(currentBuild.result,"",["slack"])
}
}
-}
\ No newline at end of file
+}
diff --git a/git-mirror-pipeline.groovy b/git-mirror-pipeline.groovy
index 9da9813..3a0f892 100644
--- a/git-mirror-pipeline.groovy
+++ b/git-mirror-pipeline.groovy
@@ -1,4 +1,5 @@
def common = new com.mirantis.mk.Common()
+def git = new com.mirantis.mk.Git()
stage("Mirror") {
node() {
try{
@@ -11,7 +12,7 @@
checkout changelog: true, poll: true,
scm: [$class: 'GitSCM', branches: pollBranches, doGenerateSubmoduleConfigurations: false, submoduleCfg: [],
extensions: [[$class: 'CleanCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: CREDENTIALS_ID, url: SOURCE_URL]]]
- common.mirrorGit(SOURCE_URL, TARGET_URL, CREDENTIALS_ID, BRANCHES)
+ git.mirrorGit(SOURCE_URL, TARGET_URL, CREDENTIALS_ID, BRANCHES)
}
} catch (Throwable e) {
// If there was an error or exception thrown, the build failed
@@ -21,4 +22,4 @@
common.sendNotification(currentBuild.result,"",["slack"])
}
}
-}
\ No newline at end of file
+}
diff --git a/release-salt-formulas-pipeline.groovy b/release-salt-formulas-pipeline.groovy
index 90ce9ef..7660636 100644
--- a/release-salt-formulas-pipeline.groovy
+++ b/release-salt-formulas-pipeline.groovy
@@ -1,13 +1,14 @@
def common = new com.mirantis.mk.Common()
+def ssh = new com.mirantis.mk.Ssh()
node() {
try{
stage("checkout") {
dir("src") {
- common.prepareSshAgentKey(CREDENTIALS_ID)
- common.ensureKnownHosts(SOURCE_URL)
+ ssh.prepareSshAgentKey(CREDENTIALS_ID)
+ ssh.ensureKnownHosts(SOURCE_URL)
git url: SOURCE_URL, branch: "master", credentialsId: CREDENTIALS_ID, poll: false
sh("git branch --set-upstream-to=origin/master")
- common.agentSh("make update")
+ ssh.agentSh("make update")
}
}
stage("tag") {
@@ -17,7 +18,7 @@
}
stage("push") {
dir("src/formulas") {
- common.agentSh("mr --trust-all -j4 --force run git push gerrit $TAG")
+ ssh.agentSh("mr --trust-all -j4 --force run git push gerrit $TAG")
}
}
} catch (Throwable e) {
@@ -27,4 +28,4 @@
} finally {
common.sendNotification(currentBuild.result,"",["slack"])
}
-}
\ No newline at end of file
+}
diff --git a/test-salt-models-pipeline.groovy b/test-salt-models-pipeline.groovy
index ebc99c9..1928e4c 100644
--- a/test-salt-models-pipeline.groovy
+++ b/test-salt-models-pipeline.groovy
@@ -1,5 +1,7 @@
def common = new com.mirantis.mk.Common()
def gerrit = new com.mirantis.mk.Gerrit()
+def ssh = new com.mirantis.mk.Ssh()
+def git = new com.mirantis.mk.Git()
node("python") {
try{
@@ -7,7 +9,15 @@
gerrit.gerritPatchsetCheckout ([
credentialsId : CREDENTIALS_ID
])
- sh("git submodule init; git submodule sync; git submodule update --recursive")
+
+ if (fileExists('classes/system') {
+ ssh.prepareSshAgentKey(CREDENTIALS_ID)
+ dir('classes/system') {
+ remoteUrl = git.getGitRemote()
+ ssh.ensureKnownHosts(remoteUrl)
+ }
+ ssh.agentSh("git submodule init; git submodule sync; git submodule update --recursive")
+ }
}
stage("test") {
wrap([$class: 'AnsiColorBuildWrapper']) {
@@ -21,4 +31,4 @@
} finally {
common.sendNotification(currentBuild.result,"",["slack"])
}
-}
\ No newline at end of file
+}