首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jenkins管道中的shell脚本是否异步运行?

Jenkins管道中的shell脚本是否异步运行?
EN

Stack Overflow用户
提问于 2018-12-10 07:48:13
回答 1查看 1.8K关注 0票数 0

我有一个管道来构建我的android应用程序。在某些阶段,我有shell脚本。当我一个接一个地运行阶段时(通过评论他人),一切都很好,但是当我一起运行它们时,我会看到奇怪的行为。

看来shell脚本运行在并行中!

这是我的个人档案:

代码语言:javascript
复制
pipeline{
    agent any

    stages{
        stage("Clean"){
          agent{
            node{
              label 'master'
              customWorkspace getMainDirectory()
            }
          }
          steps{
              sh """#!/bin/bash
                rm -rf Corona
                rm -rf native-corona-android
                cd ..
                cp -a TemplateWorkspace/. ${getCoronaBranch()}-${getNativeBrach()}
                """
          }
        }
        stage("pull native repo"){
            agent{
              node{
                label 'master'
                customWorkspace getNativeProjectPath()
              }
            }
            steps{
                echo "pulling native"
                git(
                   url: nativeRepositoryAddress,
                   credentialsId: credentialsId,
                   branch: getNativeBrach()
                )
                echo "pulling done"
            }
        }
        stage("pull corona repo"){
            agent{
              node{
                label 'master'
                customWorkspace getCoronaProjectPath()
              }
            }
            steps{
                echo "pulling corona"
                git(
                   url: coronaRepositoryAddress,
                   credentialsId: credentialsId,
                   branch: getCoronaBranch()
                )
                echo "pulling done"
            }
        }
        stage("build"){
            environment {
                docDir = getMainDirectory()
                ANDROID_HOME = getAndroidSDKLocation()
            }
            agent{
              node{
                label 'master'
                customWorkspace getNativeProjectPath()
              }
            }
            steps{
                sh """#!/bin/bash
                ./gradlew clean
                ./gradlew changeFiles --stacktrace --no-daemon
                ./gradlew assembleDebug --stacktrace --no-daemon
                """
            }
        }
        stage("move build files"){
          agent{
            node{
              label 'master'
              customWorkspace getGradleBuildLocation()
            }
          }
          steps{
              sh """#!/bin/bash
                yes | cp -rf * ../../../../JenkinsBuilds/${getOutputFolder()}/
                """
          }
        }
    }

}

我只想运行步骤同步(当然还有shell脚本),我的问题是什么?

以下是我所看到的:

在“清洁”步骤中,文件夹被删除,模板文件夹的新副本被复制到工作目录中。步骤“拉本地回购”和“拉电晕回购”做他们应该做的工作。但在“构建”一步中,我可以看到,“原生-日冕-android”文件的一部分已经消失,"gradlew“脚本被删除。我也看到了整个“原生-冠-android”文件夹被删除的情况。然后,我想“清洁”步骤中的脚本又被调用了。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2018-12-10 08:27:49

除非您使用parallel指令,否则所有步骤都应该同步运行。

你观察到了什么行为?哪些步骤是并行的?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53701423

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档