【发布时间】:2021-12-13 20:54:01
【问题描述】:
我的帐户启用了 2FA,并且我的仓库是私有的。我正在尝试使用 Jenkins 将我的 node.js 应用程序部署到 AWS Ec2 并且一切正常,包括(构建、测试、覆盖),但由于 2FA 问题,最终部署不起作用。我已经在 jenkins 中添加了我的用户名和令牌,这似乎可以工作,但是一旦我运行像 git pull 这样的 git 命令,它会在运行时询问用户名和密码,因为 Jenkins 无法连接到 github 并且无法进行任何更改.
这是部署阶段:
stage('deploy') {
steps {
withCredentials([usernamePassword(credentialsId: 'someid', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]){
echo 'Deploying to aws ec2'
sh '''#!/bin/bash
ssh ubuntu@ip-555.55.55.5 <<EOF
cd /var/www/app
sudo git reset --hard HEAD # problem is likely to be here because it requires username and password
sudo git pull
npm install
pm2 restart all
exit
EOF
'''
}
}
【问题讨论】:
-
我以为 GitHub 删除了username/password option;必须是用户名/PAT。
标签: node.js github jenkins jenkins-pipeline devops