3
1

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 CLIを用いてconfig.xmlからジョブを作成する

Posted at

わざわざ面倒な手段を取っていることは自覚してます。

Jenkinsジョブのインポートは、JENKINS_HOMEのjobsにディレクトリ作って、config.xmlを置けば良いんだけど、
事情によりサーバを直接触らせられない時にジョブをインポートする方法。

意外と?config.xmlをインポートするようなプラグインが見つからなかったので、Jenkins CLIを使ってみた。

事前に用意するもの

  • Jenkinsの管理者権限を保有したログインIDとパスワード
  • インポート対象ジョブの定義がある config.xml
  • Jenkinsからダウンロードした jenkins-cli.jar

インポート手順

  • コマンドプロンプトを開く

  • config.xml がある場所へ移動

  • 以下のコマンドを発行する

     % java -jar jenkins.cli.jar -s JenkinsのURL \
         create-job \
         --username JenkinsユーザID --password Jenkinsユーザパスワード \
         作成ジョブ名 < config.xml
    
  • Jenkinsのトップページに指定したジョブが作成されていることを確認する

注意点としては、指定するジョブ名は 半角の英数字 であることと、スペースは使えないが、アンダーバーは使用可能であること。

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?