小编eam*_*ram的帖子

当搜索的字符串不存在时,Jenkins shell 脚本返回退出代码 1

我正在 Jenkins 尝试以下操作,旨在搜索工作中的失败字符串。
这将每天运行。


def sd = "2020" + "${env.START_DATE}" + "0000"
def ed = "2020" + "${env.END_DATE}" + "2359.59"

pipeline {
    agent {label "master"}
    stages {
        stage('Build') {
            steps {

                print(sd)
                sh 'echo "Hello World"'
                sh """
                    pwd
                    #rm end-time start-time
                    #rm $WORKSPACE/$PARSING_OUTPUT
                    touch -t $sd $WORKSPACE/start-time
                    touch -t $ed $WORKSPACE/end-time
                    find /var/lib/jenkins/jobs/. -type f -newer $WORKSPACE/start-time  ! -newer $WORKSPACE/end-time -name '*' -exec grep $SEARCH_STRING /dev/null {} + >> $WORKSPACE/$PARSING_OUTPUT
                    ls -ltr
                """
            }
        post {
                always {
                    echo …
Run Code Online (Sandbox Code Playgroud)

shell jenkins jenkins-pipeline

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

jenkins ×1

jenkins-pipeline ×1

shell ×1