【问题标题】:Pushing Jar to github when a Jenkins build succeeds当 Jenkins 构建成功时将 Jar 推送到 github
【发布时间】:2012-03-12 20:38:18
【问题描述】:

我有一个简单的 Jenkins 构建,它从 github 拉下我的项目,构建它并报告构建状态。

我想配置 Jenkins 以将生成的 JAR 文件发布到我项目中的 TARGET-SNAPSHOTS 分支。

目前我的项目.gitignore的/target/*

我正在查看 GitPublisher,但这似乎将整个构建推出,而不仅仅是 jar 文件。

对最好的方法的想法/如果可能的话?

谢谢

【问题讨论】:

  • 您是否使用 maven 来构建您的项目?
  • 您是在尝试将文件添加到现有存储库并推送更改还是将文件添加到 GitHub 的下载部分?
  • @brian -- 是的 - 我正在使用 maven 构建我的项目。
  • @ŁukaszRżanek -- 我在考虑一个分支,但下载也应该可以工作。我只想让构建的 OSGI Bundle(Jar 文件)易于下载以供其他人安装(而不是让他们下载源代码和包)

标签: jar github hudson jenkins publish


【解决方案1】:

我认为你有很多可能性。其中之一是运行构建后脚本。可以写成shell。

Post build task

简单脚本:

find . -name "*.jar" -exec scp {} user@myhost.com:/path/for/build/${BUILD_TAG} \;

其他:

Publish Over ... (ssh, ftp, cifs)

【讨论】:

  • 我会尝试一下 - 我没有意识到你可以 SCP 到 github。谢谢
【解决方案2】:

由于您使用的是 maven,并且您说 github 下载部分是可以接受的,因此您可以使用 github 下载插件 - https://github.com/github/maven-plugins。作为构建的一部分,我使用它来将 Riak java 客户端部署到我们的下载部分。

在你的 ~/.m2/settings.xml 你需要:

<settings>
  <profiles>
    <profile>
      <id>github</id>
      <properties>
        <github.global.userName>YourGithubUser</github.global.userName>
        <github.global.password>YourGithubPass</github.global.password>
      </properties>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>github</activeProfile>
  </activeProfiles>
</settings>

然后在您项目的.pom 中类似:

<profile>
  <id>githubUpload</id>
  <activation>
    <property>
      <name>github.downloads</name>
      <value>true</value>
    </property>
  </activation>
  <build>
    <plugins>
      <plugin>
        <groupId>com.github.github</groupId>
        <artifactId>downloads-maven-plugin</artifactId>
        <version>0.4</version>
        <configuration>
          <description>${project.version} release of ${project.name}</description>
          <override>false</override>               
          <includeAttached>true</includeAttached>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>upload</goal>
            </goals>
            <phase>install</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

(我将其作为安装阶段的一部分进行 - 你可以随心所欲)

然后只需将 -Dgithub.downloads=true 添加到您的 maven 构建中 -

mvn install -Dgithub.downloads=true

插件的网页列出了包含/排除文件等的所有选项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-30
    • 1970-01-01
    • 1970-01-01
    • 2017-05-26
    • 2012-05-24
    • 1970-01-01
    • 1970-01-01
    • 2012-10-30
    相关资源
    最近更新 更多