← Back to team overview

sts-sponsors team mailing list archive

[Merge] ~cgrabowski/maas-ci/+git/maas-ci-internal:fix_github_push into ~maas-committers/maas-ci/+git/maas-ci-internal:main

 

Christian Grabowski has proposed merging ~cgrabowski/maas-ci/+git/maas-ci-internal:fix_github_push into ~maas-committers/maas-ci/+git/maas-ci-internal:main.

Commit message:
ensure ssh config handles proxy on push

set name and email for lander

Requested reviews:
  Adam Collard (adam-collard)
  MAAS Lander (maas-lander)

For more details, see:
https://code.launchpad.net/~cgrabowski/maas-ci/+git/maas-ci-internal/+merge/435493
-- 
Your team MAAS Committers is subscribed to branch ~maas-committers/maas-ci/+git/maas-ci-internal:main.
diff --git a/jobs/github-ci/github-ci.groovy b/jobs/github-ci/github-ci.groovy
index 91581f0..e51db73 100644
--- a/jobs/github-ci/github-ci.groovy
+++ b/jobs/github-ci/github-ci.groovy
@@ -116,6 +116,8 @@ pipeline {
                     }
                     {% else %}
                     sh '''
+                      export no_proxy="${no_proxy:-'localhost'},${MAAS_HOST}"
+                      export NO_PROXY="${NO_PROXY:-'localhost'},${MAAS_HOST}"
                       cd {{ test_dir }}
                       sudo -E -H -u ubuntu {{ test_command }}
                     '''
@@ -134,7 +136,10 @@ pipeline {
                     '''
                     archiveArtifacts artifacts: 'junit*.xml'
                     junit allowEmptyResults: true, testResults: 'junit*.xml'
-                    withCredentials([string(credentialsId: 'jenkins-maas-token', variable: '{{ api_token_env_var }}')]) {
+                    withCredentials([
+                        string(credentialsId: 'jenkins-maas-token', variable: '{{ api_token_env_var }}'),
+                        sshUserPrivateKey(credentialsId: 'maas-lander-ssh-key', keyFileVariable: 'SSHKEY', usernameVariable: 'SSHUSER')
+                    ]) {
                         {{ post_test_actions }}
                     }
                 }
diff --git a/jobs/github-ci/github-ci.yaml b/jobs/github-ci/github-ci.yaml
index 2e9b0a7..5160b93 100644
--- a/jobs/github-ci/github-ci.yaml
+++ b/jobs/github-ci/github-ci.yaml
@@ -34,6 +34,14 @@
           description: 'The Ubuntu series to build and with'
           default: '{ubuntu_series}'
       - string:
+          name: GH_USER_NAME
+          description: 'The name to use to commit results and push them'
+          default: '{lander_name}'
+      - string:
+          name: GH_USER_EMAIL
+          description: 'The email to use to commit results and push them'
+          default: '{lander_email}'
+      - string:
           name: MAAS_HOST
           description: "The IP or Hostname used in the MAAS_URL, to be added to NO_PROXY"
           default: '10.245.136.7'
@@ -69,6 +77,8 @@
     test_command: '/bin/true'
     post_test_actions: ''
     ubuntu_series: '20.04'
+    lander_name: 'MAAS Lander'
+    lander_email: 'maas-lander@xxxxxxxxxxxxx'
 
 - view-template:
     name: 'gh-{name}'
diff --git a/jobs/maas-terraform-test.yaml b/jobs/maas-terraform-test.yaml
index 5bc6c3e..2e328c6 100644
--- a/jobs/maas-terraform-test.yaml
+++ b/jobs/maas-terraform-test.yaml
@@ -36,6 +36,10 @@
             Terraform will spin up
           default: 'ipmi'
       - string:
+          name: TF_VAR_test_machine_hostname
+          description: |
+            The hostname of an existing machine in MAAS to deploy
+      - string:
           name: TF_VAR_test_machine_power_address
           description: "The IP Address for MAAS to power on the physical machine"
           default: '10.245.143.121'
diff --git a/utilities/terraform/terraform_post_actions b/utilities/terraform/terraform_post_actions
index 89a0afd..27f4c86 100755
--- a/utilities/terraform/terraform_post_actions
+++ b/utilities/terraform/terraform_post_actions
@@ -2,7 +2,7 @@
 
 export no_proxy="${no_proxy:-'localhost'},${MAAS_HOST}"
 export NO_PROXY="${NO_PROXY:-'localhost'},${MAAS_HOST}"
-export COMMIT_HASH="$(git rev-parse HEAD)"
+export GIT_SSH_COMMAND="ssh -i $SSHKEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
 
 python3 <<EOF
 import os
@@ -21,8 +21,15 @@ EOF
 
 cd /run/build/tests
 
+export COMMIT_HASH="$(git rev-parse HEAD)"
+
 ./update_results
 
+git config user.email "${GH_USER_EMAIL}"
+git config user.name "${GH_USER_NAME}"
+mkdir -p ~/.ssh/
+echo "Host github.com\n  HostName ssh.github.com\n  Port 443\n  ProxyCommand /usr/bin/nc -X connect -x squid.internal %h %p\n" >> ~/.ssh/config
+
 git add results.json
 git commit -m "updating test results for: ${COMMIT_HASH}"
-git push -u origin "${GH_BRANCH}"
+git push -u origin "${GH_TEST_BRANCH}"

Follow ups