1
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 3 years have passed since last update.

Jenkins Piplineについて

Last updated at Posted at 2021-04-04

環境

Jenkinsのパイプラインの定義はGitのリポジトリにJekinsfileを置いてそこを参照するように設定

スクリーンショット 2021-04-04 14.28.07.png

Gitには下記のJenkinsfileを置いておく

Jenkinsfile

pipeline {
   agent any
   stages {
      stage("Prepare") {
         steps {
            echo "Prepare"
         }
      }
      stage("build") {
         steps {
            echo "build"
         }
      }
      stage("Artifacts") {
         steps {
            echo "Artifacts"
         }
      }
   }
   post {
      // 完了ステータスに関係なく実行
      always {
        // ワークスペースを削除
        cleanWs()
      }
    }
}

この状態でJenkinsからビルドを実行するとこんな感じになる

スクリーンショット 2021-04-04 14.25.16.png

各項目事の説明

Declarative: Checkout SCM

GitのリポジトリのJekinsfileを参照する設定にしておくと、ビルドを実行後そのリポジトリの最新を取得してくれます

スクリーンショット 2021-04-04 14.25.16 3.png

Prepare, Build, Artifacts

Jekinsfileのstagesに含まれているstageの項目になります。

スクリーンショット 2021-04-04 14.25.16 4.png

Declarative: Post Actions

Jekinsfileのpostの内容になります
postはパイプラインまたはステージの実行の完了時に実行される内容になります。

スクリーンショット 2021-04-04 14.25.16 3.png

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