[英]How to download build output files from jenkins UI console itself
I am new Jenkins , using jenkins 1.651.3 War deployed on
Tomcat6
我是新 Jenkins ,使用部署在Tomcat6上的
jenkins
1.651.3 War
Is there any way to download Jenkins job's output file ( my job produced a jar file ) from jenkins UI Console itself ?有什么方法可以从 jenkins UI 控制台本身下载 Jenkins 作业的输出文件(我的作业生成了一个 jar 文件)?
So, could anyone suggest me is there any way or plugin available to make the each Jenkins build output files ( like Jar/War) as downloadable from the Jenkins server machine所以,任何人都可以建议我有什么方法或插件可以使每个 Jenkins 构建输出文件(如 Jar/War)可以从 Jenkins 服务器机器下载
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ NumberGenerator ---
[INFO] Building jar: /opt/cloudhost/jenkinsHome/jobs/TestGiby/workspace/NumberGenerator/target/NumberGenerator-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ NumberGenerator ---
[INFO] Installing /opt/cloudhost/jenkinsHome/jobs/TestGiby/workspace/NumberGenerator/target/NumberGenerator-0.0.1-SNAPSHOT.jar to /opt/cloudhost/software/maven/mavenRepo/com/giby/maven/NumberGenerator/0.0.1-SNAPSHOT/NumberGenerator-0.0.1-SNAPSHOT.jar
[INFO] Installing /opt/cloudhost/jenkinsHome/jobs/TestGiby/workspace/NumberGenerator/pom.xml to /opt/cloudhost/software/maven/mavenRepo/com/giby/maven/NumberGenerator/0.0.1-SNAPSHOT/NumberGenerator-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.575 s
[INFO] Finished at: 2017-02-01T05:00:44+00:00
[INFO] Final Memory: 19M/607M
[INFO] ------------------------------------------------------------------------
Finished: SUCCESS
Use Archive the artifacts
post-build step, it copies the selected artifacts in the artifacts folder.使用
Archive the artifacts
post-build 步骤,它将在 artifacts 文件夹中复制选定的 artifacts。
Then you will be able to download the file from build page itself.然后您将能够从构建页面本身下载文件。
For Pipeline you need to add it in the pipeline script itself.对于管道,您需要将其添加到管道脚本本身中。 Check for the corresponding groovy script for archive the artifacts or find the below example (this is a working code).
检查用于存档工件的相应 groovy 脚本或找到以下示例(这是一个工作代码)。
post {
always {
archive "project/embsw/debug/**/*"
stash includes: 'project/embsw/debug/project_R0.bin', name: 'debugBuiltArtifacts'
}
}
好吧,您可以右键单击“查看为无格式文本”并选择“将链接另存为”以将日志保存在您的 PC 上。
I am able to directly open the console log in Notepad++.我可以直接在 Notepad++ 中打开控制台日志。 Just right-click the "Full Log" link, copy the link address, then paste it into the "Open" dialog in Notepad++.
只需右键单击“完整日志”链接,复制链接地址,然后将其粘贴到 Notepad++ 中的“打开”对话框中。
My Jenkins server had to be configured to allow this.我的 Jenkins 服务器必须配置为允许这样做。
Just in case someone is searching how to enable this option in a Jenkinsfile, I will put an example down where I do a backup of a single table from a MariaDB database and then download it from the job build :)以防万一有人在 Jenkinsfile 中搜索如何启用此选项,我将给出一个示例,其中我从 MariaDB 数据库备份单个表,然后从作业构建中下载它:)
stage('Backup') {
steps {
script {
sh "rm -rf db.dump.sql*"
withCredentials([usernamePassword(credentialsId: 'my-database-credentials', passwordVariable: 'DB_PASSWORD', usernameVariable: 'DB_USERNAME')]) {
sh """docker run --rm -t \
-v $WORKSPACE:/data \
--entrypoint mysqldump \
mariadb -v \
-P 3306 \
-h ${DB_HOST} \
-u master \
--password="${DB_PASSWORD}" \
--default-character-set=latin1 \
--skip-lock-tables --skip-add-locks \
--single-transaction --add-drop-table --complete-insert \
--result-file="/data/db.dump.sql" ${DATABASE_NAME} ${TABLE_NAME}"""
}
sh "du -sh db.dump.sql"
archiveArtifacts artifacts: 'db.dump.sql', excludes: 'output/*.md'
}
}
}
Just add the following line in your Jenkinsfile script只需在您的 Jenkinsfile 脚本中添加以下行
archiveArtifacts artifacts: 'db.dump.sql', excludes: 'output/*.md'
Reference: test and artifacts参考:测试和工件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.