Created
May 28, 2018 14:23
-
-
Save w8r/d68bd77e41339034ed73e11b4c8c535f to your computer and use it in GitHub Desktop.
Ensure SSH keys in Jenkins slave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent { dockerfile true } | |
environment { | |
npm_config_cache = 'npm-cache' | |
} | |
stages { | |
stage('Install') { | |
steps { | |
echo 'Ensure SSH keys' | |
// set the credentials to be able to access private repos | |
withCredentials([file(credentialsId: 'sshkey', variable: 'SSHKEY')]) { | |
sh 'mkdir -p ~/.ssh' | |
sh 'cp $SSHKEY ~/.ssh/id_rsa' | |
sh 'chmod 600 ~/.ssh/id_rsa' | |
sh 'echo \'Host github.com\n StrictHostKeyChecking no\' > ~/.ssh/config' | |
} | |
echo 'Install' | |
sh 'node --version' | |
sh 'npm --version' | |
sh 'npm i' | |
} | |
} | |
stage('Unit tests') { | |
steps { | |
sh 'npm t' | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment