All Implemented Interfaces:
Configurable, KeyVal.Mixin, UtilsMixin

public class Pipeline extends HasEnvironmentVariables<Pipeline>
Represents a pipeline config object.

/*
 * Copyright 2021 ThoughtWorks, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


GoCD.script {
  pipelines {
    pipeline('website') {
      trackingTool {
        link = 'https://github.com/gocd/gocd/issues/${ID}'
        regex = ~/##(\\d+)/
      }

      materials {
        git {
          url = 'https://github.com/gocd/www.go.cd'
        }
      }
      stages {
        stage('build-website') {
          jobs {
            job('build') {
              tasks {
                exec {
                  commandLine = ['bundle', 'install']
                }
                exec {
                  commandLine = ['bundle', 'exec', 'rake', 'build']
                }
              }

              artifacts {
                build {
                  source = 'target/jcoverage'
                  destination = 'Jcoverage'
                }
              }

              tabs {
                tab('JCoverage') { path = 'Jcoverage/index.html' }
              }
            }
          }
        }
      }
    }
  }

}

  • Constructor Details

  • Method Details

    • trackingTool

      See Also:
    • timer

      See Also:
    • materials

      See Also:
    • stages

      See Also:
    • getGroup

      public String getGroup()
      The name of the pipeline group that this pipeline belongs to.
    • getDisplayOrder

      public Integer getDisplayOrder()
      Use this integer to order the display of pipelines on the dashboard. If multiple pipelines have the same displayOrder value, their order relative to each other will be indeterminate.
    • getLabelTemplate

      public String getLabelTemplate()
      Pipeline label templates provide a means to label a pipeline or artifacts using a counter, or material revision (or both).

      Valid substitutions are:

      Valid substitutions
      ${COUNT}The pipeline counter (starts at 1).
      ${<material-name>}The revision of the material named "material-name". The "material-name" can be the name of an SCM material, or a pipeline material.
      ${<material-name>[:<length>]}The first "length" characters of revision of the material named "material-name".
      #{<parameter-name>}Substitute the value of the parameter named "parameter-name".

      An example of a label template is:

      • 15.1-${COUNT} or
      • 15.1-${COUNT}-${svn} or
      • 15.1-${COUNT}-${git[:7]}
    • getLockBehavior

      public String getLockBehavior()
      The possible values are none, lockOnFailure or unlockWhenFinished.

      When set to lockOnFailure, GoCD ensures that only a single instance of a pipeline can be run at a time and the pipeline will be locked if it fails, unless it is the last stage which fails.

      When set to unlockWhenFinished, GoCD ensures that only a single instance of a pipeline can be run at a time, and the pipeline will be unlocked as soon as it finishes (success or failure), or reaches a manual stage.

      The default value is none.

    • getTemplate

      public String getTemplate()
      The name of the template that this pipeline references. If set, no stages may be defined in this pipeline.
    • getParams

      public Map<String,String> getParams()
      The list of parameter substitutions to be used in a pipeline or a template.

      /*
       * Copyright 2021 ThoughtWorks, Inc.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       *     http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */


        pipeline('build') {
          params = [
            OS     : 'linux',
            BROWSER: 'firefox'
          ]

          stages {
            stage('foo') {
              jobs {
                job('foo') {
                  tasks {
                    exec {
                      commandLine = ['./gradle', 'test', '-Pos=#{OS}', '-Pbrowser=#{BROWSER}']
                    }
                  }
                }
              }
            }
          }
        }

      See Also:
    • setGroup

      public void setGroup(String group)
      The name of the pipeline group that this pipeline belongs to.
    • setDisplayOrder

      public void setDisplayOrder(Integer displayOrder)
      Use this integer to order the display of pipelines on the dashboard. If multiple pipelines have the same displayOrder value, their order relative to each other will be indeterminate.
    • setLabelTemplate

      public void setLabelTemplate(String labelTemplate)
      Pipeline label templates provide a means to label a pipeline or artifacts using a counter, or material revision (or both).

      Valid substitutions are:

      Valid substitutions
      ${COUNT}The pipeline counter (starts at 1).
      ${<material-name>}The revision of the material named "material-name". The "material-name" can be the name of an SCM material, or a pipeline material.
      ${<material-name>[:<length>]}The first "length" characters of revision of the material named "material-name".
      #{<parameter-name>}Substitute the value of the parameter named "parameter-name".

      An example of a label template is:

      • 15.1-${COUNT} or
      • 15.1-${COUNT}-${svn} or
      • 15.1-${COUNT}-${git[:7]}
    • setLockBehavior

      public void setLockBehavior(String lockBehavior)
      The possible values are none, lockOnFailure or unlockWhenFinished.

      When set to lockOnFailure, GoCD ensures that only a single instance of a pipeline can be run at a time and the pipeline will be locked if it fails, unless it is the last stage which fails.

      When set to unlockWhenFinished, GoCD ensures that only a single instance of a pipeline can be run at a time, and the pipeline will be unlocked as soon as it finishes (success or failure), or reaches a manual stage.

      The default value is none.

    • setTemplate

      public void setTemplate(String template)
      The name of the template that this pipeline references. If set, no stages may be defined in this pipeline.
    • setParams

      public void setParams(Map<String,String> params)
      The list of parameter substitutions to be used in a pipeline or a template.

      /*
       * Copyright 2021 ThoughtWorks, Inc.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       *     http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */


        pipeline('build') {
          params = [
            OS     : 'linux',
            BROWSER: 'firefox'
          ]

          stages {
            stage('foo') {
              jobs {
                job('foo') {
                  tasks {
                    exec {
                      commandLine = ['./gradle', 'test', '-Pos=#{OS}', '-Pbrowser=#{BROWSER}']
                    }
                  }
                }
              }
            }
          }
        }

      See Also:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class HasEnvironmentVariables<Pipeline>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class HasEnvironmentVariables<Pipeline>
    • toString

      public String toString()
      Overrides:
      toString in class HasEnvironmentVariables<Pipeline>