I'm working with pipelines in Jenkins in a environment which already has configured a pipeline script from SCM which then uses a groovy file for the stages/jobs inside the pipeline. This scripts are on Bitbucket in a master branch.
Every time jenkins jobs starts it call master branch and it runs with no problem and the stages of the pipeline are run.
Now I created a new branch on bitbucket and modified the groovy file to include some more steps (like running unit tests and some more stuff) and I would like that jenkins runs that script but with the branch I specified (the one I created).
Thing is that eventhough I specified my branch in in "branch specifier", jenkins still runs the master branch. Here are some images of what I have configured.
How can I specify the branch I want to be run on the pipeline script from SCM?
Lightweight checkout support not available, falling back to full checkout.
Checking out git [email protected]/xxxxxx.git into /data/jobs/extractor-pipeline-test-dev/workspace@script to read extractor-dev/Jenkinsfile
Cloning the remote Git repository
Cloning repository [email protected]:xxxxxx/xxxxxxxxxx.git
> /usr/bin/git init /data/jobs/extractor-pipeline-test-dev/workspace@script # timeout=10
Fetching upstream changes from [email protected]:xxxx/xxxxxx.git
> /usr/bin/git --version # timeout=10
> /usr/bin/git fetch --tags --progress [email protected]:xxxxxx/deploy.git +refs/heads/*:refs/remotes/origin/*
> /usr/bin/git config remote.origin.url [email protected]:xxxxx/deploy.git # timeout=10
> /usr/bin/git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> /usr/bin/git config remote.origin.url [email protected]:xxxxxxx/deploy.git # timeout=10
Fetching upstream changes from [email protected]:xxxxx/deploy.git
> /usr/bin/git fetch --tags --progress [email protected]:grydev/gp_deploy.git +refs/heads/*:refs/remotes/origin/*
**Seen branch in repository origin/DEVOPS-568-pipeline-ci
Seen branch in repository origin/dev
Seen branch in repository origin/master**
Seen 3 remote branches
> /usr/bin/git tag -l # timeout=10
Checking out Revision e3270789a8181b26464f878bfccdf39b3fdabcb0 (master)
Commit message: " ....."
> /usr/bin/git config core.sparsecheckout # timeout=10
> /usr/bin/git checkout -f e3270789a8181b26464f878bfccdf39b3fdabcb0
> /usr/bin/git rev-list e3270789a8181b26464f878bfccdf39b3fdabcb0 # timeout=10
This is the groovy file, but groovy files does steps of the code that will be deployed. It doesn't run any jenkin script. Where it says "master" is of maser code to be deploy and not the deploy script.
Groovy file:
def call(body) {
def config = [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body()
def artifactName = 'imp'
def artifactExt = '.war'
def artifactVersion = '0.0.1'
def buildPath = 'target/'
def warFile = artifactName + '-' + artifactVersion + artifactExt
def warPath = buildPath + warFile
def warNoVersion = artifactName + artifactExt
def deployPath = '/var/lib/tomcat8/webapps/'
def deployFile = deployPath + warNoVersion
node {
// Clean workspace before doing anything
//deleteDir()
try {
stage ('Code Checkout') {
git branch: 'master',
credentialsId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
url: 'ssh://[email protected]/xxxxx/xxxximporter'