在PR上触发Jenkins到分支,并使用JenkinsFile合并到分支

时间:2018-11-01 22:00:58

标签: jenkins jenkins-pipeline

当我将PR发送到Develop分支时如何开始Jenkins的工作,而当我合并到该分支时也如何开始。

使用以下代码,它会触发PR的两个if块 我试图使用下面的代码无法正常工作

if (env.BRANCH_NAME != 'master') {   if
  (env.BRANCH_NAME.toLowerCase().contains('pr')) {

      try {

        stage 'Checkout Code'
        bogieNode {
          deleteDir()
          echo 'Pulling...' + env.BRANCH_NAME + env.CHANGE_ID
          checkoutCode {}
          project.loadProperties()

          stash 'sources'
        }


      } catch (Exception ex) {
        sendFailureNotifications(
                emailCulprits: true, // emails the suspected commit culprit(s)
                notifySlackChannel: 'xxxxxxx', // send notification to the team's slack channel
        )

        throw ex // re-throw so that the exception bubbles up to the console
      }   } }


      if (env.BRANCH_NAME != 'master') {

        try {

          stage 'Checkout Code'
          bogieNode {
            deleteDir()
            echo 'Hellllooooooooooooooo Pulling...' + env.BRANCH_NAME
            checkoutCode {}
            project.loadProperties()

            stash 'sources'
          }
        } catch (Exception ex) {
          sendFailureNotifications(
                  emailCulprits: true, // emails the suspected commit culprit(s)
                  notifySlackChannel: 'xxxxxx', // send notification to the team's slack channel
          )

          throw ex // re-throw so that the exception bubbles up to the console
        }


        }

0 个答案:

没有答案