Jenkinsfile doubts

46 views
Skip to first unread message

Joaquin Henriquez

unread,
Jul 20, 2017, 5:41:26 AM7/20/17
to jenkins...@googlegroups.com

HI ppl,

 

I have the bellow Jenkinsfile and I want to either:

1)      Include the node sectin inside the pipeline (but needs to run on the master while the other will run on the slave)

2)      Either I need the jiraTicket variable to be pass to the Building stage (actually is is not cause it only last until the end of the node)

 

Thanks for the help

 

Jo

 

properties([[$class: 'GitLabConnectionProperty', gitLabConnection: 'GitLab']])

node {

   stage('JIRA') {

    def issue = [fields: [ project: [key: 'JIRAKEY'],

                                 assignee: [name: 'devops'],

                                 summary: "Jenkins Build ${env.JOB_NAME} #${env.BUILD_ID} Ticket",

                                 description: "New JIRA Ticket created on ${env.BUILD_TIMESTAMP} from Jenkins. URL: ${env.JENKINS_URL}",

                                 priority: [name: 'Medium'],

                                 labels: ['Jenkins'],

                                 issuetype: [name: 'Jenkins']]]

 

    def newIssue = jiraNewIssue issue: issue, site: 'JIRASITE'

 

    def jiraTicket = newIssue.data.key

    echo "${jiraTicket}"

    }

}

pipeline {

  agent { label 'Slave_CentOS7' }

    stages {

        stage('Build') {

            steps {

                echo 'Building..'

                                            //jiraAddComment idOrKey: "${jiraTicket}", comment: 'test comment'

                sh 'ls -lrt'

            }

        }

        stage('Test') {

            steps {

                echo 'Testing..'

                sh 'ls -lrt'

            }

        }

        stage('Deploy') {

            steps {

                echo 'Deploying....'

            }

        }

    }

    post {

      always {

            echo 'Always'

      }

      success {

                          updateGitlabCommitStatus(name: 'build', state: 'success')

      }

      failure {

            updateGitlabCommitStatus(name: 'build', state: 'failed')

      }

    }

}

Reply all
Reply to author
Forward
0 new messages