0
JenkinsジョブでJenkinsバックアッププロセスを自動化したいと思います。私はジェンキンスでバックアップを実行する仕事としてフリースタイルの仕事を作成しました。目標は、JenkinsのホームディレクトリをBitbucketにバックアップすることです。Jenkinsバックアップ用Jenkinsフリースタイルジョブ
- ジョブはマスターノード上で実行するように制限されています。
- Jenkinsのホームディレクトリは、gitリポジトリとして初期化されています。
- Jenkinsがインストールされているマシン上のrootユーザーのSSHキーが、バックアップリポジトリにアクセスできるBitbucketアカウントのSSHキーのリストに追加されています。
この仕事のために定義された単一のビルドステップがあります:私は仕事を構築する場合
cd /var/lib/jenkins
git add --all
git commit -m "Jenkins automated backup change" || true
git push
は、私が失敗したジョブのコンソール出力に次のように受信します。
Started by user anonymous
Building on master in workspace /var/lib/jenkins/jobs/JenkinsBackup/workspace
[workspace] $ /bin/sh -xe /tmp/hudson7036134295202405264.sh
+ cd /var/lib/jenkins
+ git add --all
+ git commit -m Jenkins automated backup change
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <[email protected](none)>) not allowed
+ true
+ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Build step 'Execute shell' marked build as failure
Warning: this build has no associated authentication, so build permissions may be lacking, and downstream projects which cannot even be seen by an anonymous user will be silently skipped
Finished: FAILURE
これは、Jenkinsのホームディレクトリ内でgit config -l
コマンドを実行すると、次の情報が生成されるため、奇妙なエラーのようです。
[email protected]
user.name=Jenkins Automated Backup
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=ssh://[email protected]###.##.##.###:7999/at/jenkinsbackup.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
ここで何が起こっているのでしょうか?ジョブのコンソール出力に表示されるエラーメッセージは、問題の正確な原因についてはあまり明確ではありません。
ありがとうございました!
これは素晴らしい情報です!この問題のトラブルシューティングでは、私が実行していた致命的な終わりの1つは、Jenkinsサーバーがシェルコマンドを実行しようとしているユーザーを特定する方法でした。私はこの情報を持っていることを調査し、結果を投稿します! – J0991
次の質問として、このユーザーがGitコマンドを実行しようとしたときに使用するSSH鍵の場所を知りたいのですが?私はその特定のユーザのためのSSH鍵がここで問題かもしれないと思います。 – J0991