简体   繁体   English

如何从 jenkins UI 控制台本身下载构建输出文件

[英]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.

相关问题 如何从 Jenkins 下载巨大的控制台输出 - How to download a huge console output from Jenkins Jenkins api4jenkins 下载最后一个构建作业控制台输出 - Jenkins api4jenkins download last build job console output 如何使Jenkins构建输出可从Jenkins服务器计算机本身下载? - How to make the Jenkins build output as downloadable from Jenkins server machine itself? 在终端使用 curl 调用构建后,如何在终端构建期间查看 Jenkins 控制台输出? - How to view Jenkins console output during a build from the terminal after invoking build using curl from the terminal? Selenium - 从 UI 启动下载时文件未下载到 Jenkins 目录 - Selenium - Files not downloading to Jenkins directory when the download is initiated from UI 带有Jenkins的xUnit:如何在构建控制台输出中显示颜色? - xUnit with Jenkins: how to display colors in the Build Console Output? 如何在 hudson/jenkins 构建输出控制台中显示超链接 - How to display a hyperlink in hudson/jenkins build output console 远程触发构建后如何获取Jenkins的“控制台输出”? - How to get Jenkins “Console Output” after triggering build remotely? 如何删除旧的 jenkins build 的控制台 output - how to remove old jenkins build's console output Jenkins输出控制台的安全性构建失败 - Jenkins security of Output console faild build
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM