Next, you will add the Build App Stage to your pipeline.
The git branch step will clone the openshift-tasks project with the git branch locally from your gogs server to your jenkins node. The jenkins node is leveraging the git jenkins plugin to communicate to gogs.
Please note that we are leveraging the eap-7 branch in our git project and not the master branch.
In Builds > Pipelines > tasks-pipeline > Actions > Edit
Append the text below to the bottom of the Jenkins Pipeline Configuration. Please make sure to append to the beginning of the next line.
stages {
stage('Build App') {
steps {
git branch: 'eap-7', url: 'http://gogs:3000/gogs/openshift-tasks.git'
script {
def pom = readMavenPom file: 'pom.xml'
version = pom.version
}
sh "${mvnCmd} install -DskipTests=true"
}
}
Your Jenkinsfile should look like this.
If you’d like to do a test of first pipeline stage, add the following brackets at the end of your Jenkinsfile. Make sure to append to the beginning of the last line.
}
}
Your Jenkinsfile should look like this
Click Save
Go back to Builds > Pipelines
Click Start Pipeline
You should see your first stage run successfully.
Please delete the brackets you just added once testing is complete. We can add them later if you’d like to test your pipeline as you go along.
}
}
Click Save
View your gogs pod and click select the route (https://gogs…) to log into your gogs server.
Use the user name and password given to you by your instructor.
View the source of the openshift-tasks project in your gogs server.
Maven install will run through the Maven lifecycle and skip the tests. We will execute tests later in the pipeline.