1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JenkinsからGithubに自動コミットさせるためにやること

1
Last updated at Posted at 2019-04-17

備忘です

JenkinsからGithubに自動コミットさせるためにやること

作業

  1. githubに鍵でログインできるようにする
  2. Jenkinsにプラグイン入れる
    • "git branch"
    • "sshagent"
  3. groovy書く

注意点

サンプルソース

  • 以下のバージョンで実施

SSH Agent Plugin : 1.17
SSH Credentials Plugin : 1.15
Git plugin : 3.9.3


* cloneは以下の感じ
    - cloneはsshでやる
    - その際は httpsではないので気を付ける

stage('GitClone') {
steps {
git_url = "git@github.com:xxxxxx/xxxxxxxxxxxxxx.git"
git branch: "develop", credentialsId: "xxxx-github-key", url: "${git_url}"
}
}


* push は以下の感じ
    - sshagentでpushする必要アリ

stage('GitPush') {
steps {
sshagent (credentials: ['xxxx-github-key']) {
sh('git push origin develop')
}
}
}



1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?