Jenkins自由式Jenkins备份工作

时间:2017-06-28 19:42:39

标签: git jenkins backup jobs ssh-keys

我想使用Jenkins工作自动化我们的Jenkins备份过程。我在Jenkins创建了一个自由式作业,作为执行备份的工作。目标是将Jenkins主目录备份到Bitbucket。

  • 作业仅限于在主节点上运行。
  • 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 "you@example.com"
  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 <jenkins@c2failover-VirtualBox.(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命令时,会产生以下信息:

user.email=jenkins@jenkins.com
user.name=Jenkins Automated Backup
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=ssh://git@###.##.##.###:7999/at/jenkinsbackup.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

这里可能会发生什么?在作业的控制台输出中提供的错误消息不清楚问题的确切原因。

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

您是否可能使用其他用户(例如root)运行Jenkins实例?

您可以仔细检查http://<yourJenkinsURL>/systemInfo中的user.name变量。