2017-05-18 7 views
0

ビルド+公開タスクをすべて委任するために、sbt-releaseプラグインをプロジェクトに統合しています。dockerを新しいタグ付きのsbt-releaseプロセスに追加する

基本的に必要なのはすべてですが、追加のリリースステップであるDockerイメージを公開しています。これは、(thisあたりとして)私の現在のreleaseProcessです:

releaseProcess := Seq[ReleaseStep](
    checkSnapshotDependencies, 
    inquireVersions, 
    runTest, 
    setReleaseVersion, 
    commitReleaseVersion, 
    tagRelease, 
    //publishArtifacts, 
    releaseStepCommand("docker"), 
    setNextVersion, 
    commitNextVersion 
    //pushChanges, 
) 

それが結果ドッカーの画像が取得するタグを除いて、ほとんどは結構なのです(コメントプッシュに関連するものは、上流何かを壊しません)。例えば

、プロジェクトがバージョン0.17.0-SNAPSHOTだった、と私はバージョン1.0.0をリリースしたかった、このような何かが起こる場合:

[develop] ✓ [17:54:22] lithium : ~/devel/some-company/some-app 
➤ sbt clean "release skip-tests" 
[info] Loading project definition from /opt/devel/some-company/some-app/project 
[info] Updating {file:/opt/devel/some-company/some-app/project/}some-app-build... 
[info] Resolving org.fusesource.jansi#jansi;1.4 ... 
[info] Done updating. 
[info] Set current project to someapp (in build file:/opt/devel/some-company/some-app/) 
[warn] Multiple resolvers having different access mechanism configured with same name 'local'. To avoid conflict, Remove duplicate project resolvers (`resolvers`) or rename publishing resolver (`publishTo`). 
[warn] Credentials file /var/jenkins_home/credentials/nexus_creds does not exist 
[success] Total time: 0 s, completed May 18, 2017 5:54:56 PM 
[info] Starting release process off commit: a7acde4d0e943be1e4befa6cc70dc873e164044a 
[warn] Multiple resolvers having different access mechanism configured with same name 'local'. To avoid conflict, Remove duplicate project resolvers (`resolvers`) or rename publishing resolver (`publishTo`). 
[warn] Credentials file /var/jenkins_home/credentials/nexus_creds does not exist 
[info] Updating {file:/opt/devel/some-company/some-app/}root... 
[info] Done updating. 
[warn] Found intransitive dependency (net.logstash.logback:logstash-logback-encoder:4.7) while publishMavenStyle is true, but Maven repositories 
[warn] do not support intransitive dependencies. Use exclusions instead so transitive dependencies 
[warn] will be correctly excluded in dependent projects. 
[warn]    
Release version [0.17.0] : 1.0.0 
Next version [1.0.1-SNAPSHOT] : 
[info] Setting version to '1.0.0'. 
[info] Reapplying settings... 
[info] Set current project to someapp (in build file:/opt/devel/some-company/some-app/) 
[info] [develop db69b0a] Setting version to 1.0.0 
[info] 1 file changed, 1 insertion(+), 1 deletion(-) 
[info] Reapplying settings... 
[info] Set current project to someapp (in build file:/opt/devel/some-company/some-app/) 
[info] Packaging /opt/devel/some-company/some-app/target/scala-2.11/someapp_2.11-0.17.0-SNAPSHOT-sources.jar ... 
[warn] Multiple resolvers having different access mechanism configured with same name 'local'. To avoid conflict, Remove duplicate project resolvers (`resolvers`) or rename publishing resolver (`publishTo`). 
[warn] Credentials file /var/jenkins_home/credentials/nexus_creds does not exist 
[info] Done packaging. 
[info] Wrote /opt/devel/some-company/some-app/target/scala-2.11/someapp_2.11-0.17.0-SNAPSHOT.pom 
Warning: node.js detection failed, sbt will use the Rhino based Trireme JavaScript engine instead to run JavaScript assets compilation, which in some cases may be orders of magnitude slower than using node.js. 
[info] Packaging /opt/devel/some-company/some-app/target/scala-2.11/someapp_2.11-0.17.0-SNAPSHOT-web-assets.jar ... 
[info] Done packaging. 
[info] Compiling 107 Scala sources and 36 Java sources to /opt/devel/some-company/some-app/target/scala-2.11/classes... 
[info] Main Scala API documentation to /opt/devel/some-company/some-app/target/scala-2.11/api... 
[warn] Class javax.annotation.CheckReturnValue not found - continuing with a stub. 
[warn] /opt/devel/some-company/some-app/app/services/DOPXHandlerActor.scala:44: non-variable type argument services.DOPX in type pattern List[services.DOPX] (the underlying of List[services.DOPX]) is unchecked since it is eliminated by erasure 
[warn]  case reqs:List[DOPX] => withMDC { // PASAR A CASE CLASS 
[warn]    ^
[warn] /opt/devel/some-company/some-app/app/services/DOPXHandlerActor.scala:44: non-variable type argument services.DOPX in type pattern List[services.DOPX] (the underlying of List[services.DOPX]) is unchecked since it is eliminated by erasure 
[warn]  case reqs:List[DOPX] => withMDC { // PASAR A CASE CLASS 
[warn]    ^
[warn] /opt/devel/some-company/some-app/app/controllers/TransactionController.scala:79: match may not be exhaustive. 
[warn] It would fail on the following input: (None, Success(_)) 
[warn]    paymentConfirmationsService.confirm(siteId, chargeId, operationResource, request.headers.get("user")) map { _ match { 
[warn]                               ^
[warn] there were 15 feature warnings; re-run with -feature for details 
[warn] /opt/devel/some-company/some-app/app/services/DistributedTransactionProcessor.scala:139: match may not be exhaustive. 
[warn] It would fail on the following input: Some(_) 
[warn]  failureResponse match { 
[warn] ^
[warn] /opt/devel/some-company/some-app/app/services/DistributedTransactionProcessor.scala:312: match may not be exhaustive. 
[warn] It would fail on the following inputs: (_, Failure(_)), (_, Success(_)) 
[warn]  distributedOperationProcessor.processDistributedOPx(opDataFatherFixed.chargeId, Rechazada(), opDataFatherFixed, None, meanPayment, Some(refundSubPaymentOperations)).map(pr => pr match { 
[warn]                                              ^
model contains 337 documentable templates 
[warn] /opt/devel/some-company/some-app/app/services/refunds/RefundService.scala:346: match may not be exhaustive. 
[warn] It would fail on the following input: None 
[warn]     operation.sub_transactions.find { subTx => subTx.subpayment_id.get == subpaymentId } match { 
[warn]            ^
[warn] /opt/devel/some-company/some-app/app/services/ApplicationTimer.scala:9: Could not find any member to link for "ApplicationLifecycle". 
[warn] /** 
[warn]^
[warn] three warnings found 
[info] Main Scala API documentation successful. 
[info] Packaging /opt/devel/some-company/some-app/target/scala-2.11/someapp_2.11-0.17.0-SNAPSHOT-javadoc.jar ... 
[info] Done packaging. 
[warn] there were 15 feature warnings; re-run with -feature for details 
[warn] 30 warnings found 
[warn] bootstrap class path not set in conjunction with -source 1.6 
[info] /opt/devel/some-company/some-app/app/legacy/some-company/sps/domain/DBParametros.java: Some input files use unchecked or unsafe operations. 
[info] /opt/devel/some-company/some-app/app/legacy/some-company/sps/domain/DBParametros.java: Recompile with -Xlint:unchecked for details. 
[info] Packaging /opt/devel/some-company/some-app/target/scala-2.11/someapp_2.11-0.17.0-SNAPSHOT.jar ... 
[info] Done packaging. 
[info] Packaging /opt/devel/some-company/some-app/target/scala-2.11/someapp_2.11-0.17.0-SNAPSHOT-sans-externalized.jar ... 
[info] Done packaging. 
[info] Sending build context to Docker daemon 108.9MB 
[info] Step 1/8 : FROM lapp-dvde004:5000/java-alpine:latest 
[info] ---> fd94b5262b7b 
[info] Step 2/8 : MAINTAINER Redbee 
[info] ---> Using cache 
[info] ---> 2905e1a8a792 
[info] Step 3/8 : WORKDIR /opt/docker 
[info] ---> Using cache 
[info] ---> 0b2f169737f6 
[info] Step 4/8 : ADD opt/ /opt 
[info] ---> a973fb66a793 
[info] Removing intermediate container f6da68f8a1c3 
[info] Step 5/8 : ADD opt/docker/conf/jce_policy-8.tar.gz /usr/lib/jvm/default-jvm/jre/lib/security/ 
[info] ---> 3fda5972ddd5 
[info] Removing intermediate container cb10f1fcf2dd 
[info] Step 6/8 : RUN chown -R daemon:daemon . 
[info] ---> Running in 867093c046e0 
[info] ---> 60a969ff427c 
[info] Removing intermediate container 867093c046e0 
[info] Step 7/8 : USER daemon 
[info] ---> Running in a7fa422e326c 
[info] ---> 8857a5a5392b 
[info] Removing intermediate container a7fa422e326c 
[info] Step 8/8 : ENTRYPOINT /opt/docker/conf/wrapper.sh 
[info] ---> Running in 31887383f984 
[info] ---> 2418dba2d69e 
[info] Removing intermediate container 31887383f984 
[info] Successfully built 2418dba2d69e 
[info] Successfully tagged lapp-dvde004:5000/someapp:0.17.0-SNAPSHOT 
[info] Built image lapp-dvde004:5000/someapp:0.17.0-SNAPSHOT 
[info] Update Latest from image lapp-dvde004:5000/someapp:0.17.0-SNAPSHOT 
[success] Total time: 58 s, completed May 18, 2017 5:56:07 PM 
[info] Setting version to '1.0.1-SNAPSHOT'. 
[info] Reapplying settings... 
[info] Set current project to someapp (in build file:/opt/devel/some-company/some-app/) 
[info] [develop a1dd63d] Setting version to 1.0.1-SNAPSHOT 
[info] 1 file changed, 1 insertion(+), 1 deletion(-) 

悲しいことに、私はコードをハイライト表示することはできませんが、それは言います:

[info] Setting version to '1.0.0'. 
[info] Reapplying settings... 

そして構築されたイメージがある:私の限られた理解で

[info] Built image lapp-dvde004:5000/someapp:0.17.0-SNAPSHOT 

、それは見ますmsはsbt-releaseとsbt-docker(またはsbt-native-packager、私は両方とも試しました)のように同じビルドコンテキストを共有していませんか?それらの線に沿って何か?

sbt-releaseはsbt-dockerが起動する前にversion.sbtファイルを正常に変更しますが、後者はそれに気を付けません。

アイデア?

PS:Funfact:This question明らかに回答があった(または少なくとも彼の要件は私のものと一致した)ので、pandaforme、これを読んだら、なぜその要点を削除したのですか? :(再アップロード前述の要旨は、それが今では

を働いて、私は二つのことに実装驚くべきpandaformeへ

+0

私は[pandaforme ](https://stackoverflow.com/users/1834805/pandaforme)、私はDockerの画像を公開するという問題を解決する新しい要点(2017年5月19日に作成)を見つけました。 https://gist.github.com/pandaforme/e378dc3f1f32aa252b14e40937491e9c – Shonzilla

答えて

0

ありがとう:。また、ドッカーイメージを構築する「リリース」プロセスを、また、カスタム「公開」に拡張子の一種であるタスク「publishSnapshotは」(スナップショットを公開し、それがドッキングウィンドウの画像です。また、「私はちょうどsbt publish dockerBuildAndPushを行う可能性が過剰性能」として知られている)

実装を、誰もがそれを必要とする場合:

val publishDocker = ReleaseStep(action = st => { 
    val extr: Extracted = Project.extract(st) 
    val ref: ProjectRef = extr.get(thisProjectRef) 
    extr.runAggregated(
    sbtdocker.DockerKeys.dockerBuildAndPush in sbtdocker.DockerPlugin.autoImport.docker in ref, 
    st 
) 
    st 
}) 

lazy val publishSnapshot = taskKey[Unit]("Publish a Snapshot and it's Docker image") 
publishSnapshot in Compile := Def.sequential(
    publish in Compile, 
    sbtdocker.DockerKeys.dockerBuildAndPush in sbtdocker.DockerPlugin.autoImport.docker 
).value 

releaseProcess := Seq[ReleaseStep](
    checkSnapshotDependencies, 
    inquireVersions, 
    runTest, 
    setReleaseVersion, 
    commitReleaseVersion, 
    tagRelease, 
    publishArtifacts, 
    publishDocker, 
    setNextVersion, 
    commitNextVersion, 
    pushChanges 
) 
関連する問題