[JIRA] (JENKINS-60392) Allow environment variables with Bitbucket Server Integration Pipeline

2 views
Skip to first unread message

bcoveny@nycm.com (JIRA)

unread,
Dec 6, 2019, 1:07:02 PM12/6/19
to jenkinsc...@googlegroups.com
Bruce Coveny created an issue
 
Jenkins / Bug JENKINS-60392
Allow environment variables with Bitbucket Server Integration Pipeline
Issue Type: Bug Bug
Assignee: Kristy Hughes
Components: atlassian-bitbucket-server-integration-plugin
Created: 2019-12-06 18:06
Environment: Jenkins 2.207
Bitbucket Server Integration 1.0.3
Priority: Minor Minor
Reporter: Bruce Coveny

When creating a pipeline build none of the options allow environment variables. The documentation I found at https://jenkins.io/doc/pipeline/steps/atlassian-bitbucket-server-integration/ states that the branch name should be able to use environment variable, however, it doesn't appear to mark it up.

 

Hard Coded Example:

branches: [[name: 'branchname']]

Results:

Produces a scan just on branch with name 'branchname'

 

Environment Example 1:

branches: [[name: '${ENV_VARNAME}']]

Result:

Produces a scan of all branches in all the repoisotry

 

Environment Example 2:

branches: [[name: '${env.ENV_VARNAME}']]

 Result:

Stack Exception 

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

mhenschke@atlassian.com (JIRA)

unread,
Feb 3, 2020, 6:55:04 PM2/3/20
to jenkinsc...@googlegroups.com
Martin Henschke edited a comment on Bug JENKINS-60392
 
Re: Allow environment variables with Bitbucket Server Integration Pipeline
Hi Bruce,

I wasn't able to reproduce this issue. I created an environment table similar to [
this|[ https://jenkins.io/doc/pipeline/tour/environment/] ,] and the variable was substituted correctly. I notice in your example, you use single quotes- which when I did would attempt to scan for a branch named literally named ${ENV_VARNAME}, but with double quotes, the name was correctly substituted.

Could you possibly provide a more complete Jenkinsfile and a snippet from the build logs, so we can investigate further?

mhenschke@atlassian.com (JIRA)

unread,
Feb 3, 2020, 6:55:05 PM2/3/20
to jenkinsc...@googlegroups.com

Hi Bruce,

I wasn't able to reproduce this issue. I created an environment table similar to [this|https://jenkins.io/doc/pipeline/tour/environment/,] and the variable was substituted correctly. I notice in your example, you use single quotes- which when I did would attempt to scan for a branch named literally named ${ENV_VARNAME}, but with double quotes, the name was correctly substituted.

Could you possibly provide a more complete Jenkinsfile and a snippet from the build logs, so we can investigate further?

dkjellin@atlassian.com (JIRA)

unread,
Feb 12, 2020, 9:49:05 PM2/12/20
to jenkinsc...@googlegroups.com

bcoveny@nycm.com (JIRA)

unread,
Feb 25, 2020, 4:11:06 PM2/25/20
to jenkinsc...@googlegroups.com
Bruce Coveny commented on Bug JENKINS-60392
 
Re: Allow environment variables with Bitbucket Server Integration Pipeline

Martin Henschke

It appears using double quotes worked for the branch name but it does not appear to work for other variables like credentialsId and produces an error.  Please note values have been changed from hard-coded values for data sensitivity reasons.

Example call:

 

bbs_checkout branches: bbs_checkout branches:  [[name: "${env.BRANCH}"]],  credentialsId: "${env.CREDENTIALS_ID}",  id: 'id',  mirrorName: '',  projectName: 'project',  repositoryName: 'repo',  serverId: 'serverid'

Log output:

 

 

[Pipeline] bbs_checkout
using credential [proper-credential-id]
 > git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git.exe config remote.repo.url https://localhost:8443/scm/project/repo.git # timeout=10
Fetching upstream changes from https://localhost:8443/scm/project/repo.git
 > git.exe --version # timeout=10
using GIT_ASKPASS to set credentials Signon
 > git.exe fetch --tags --force --progress -- https://localhost:8443/scm/project/repo.git +refs/heads/*:refs/remotes/repo/* # timeout=10
 > git.exe rev-parse "repo/*master^{commit}" # timeout=10
 > git.exe rev-parse "develop^{commit}" # timeout=10
[Pipeline] }
Posting build status of FAILED to Bitbucket ServerERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE

Taking out the "${env.CREDENTIALS_ID}" and changing to something like 'hardcoded-credential-id' works.

This would work better if the payload configured in the Jenkins job could be injected as per issue JENKINS-60340 and not having to duplicate these values in the Jenkins job and in the Jenkinsfile.  We have different values for these based on different branches for access level information which is why we need to change the values around and not hard-code them in the Jenkinsfile.

bcoveny@nycm.com (JIRA)

unread,
Feb 25, 2020, 4:12:03 PM2/25/20
to jenkinsc...@googlegroups.com
Bruce Coveny edited a comment on Bug JENKINS-60392
[~mhenschke_atlassian]


It appears using double quotes worked for the branch name but it does not appear to work for other variables like credentialsId and produces an error.  Please note values have been changed from hard-coded values for data sensitivity reasons.

Example call:

 
{code:java}

bbs_checkout branches: bbs_checkout branches:  [[name: "${env.BRANCH}"]],  credentialsId: "${env.CREDENTIALS_ID}",  id: 'id',  mirrorName: '',  projectName: 'project',  repositoryName: 'repo',  serverId: 'serverid'
{code}
Log output:


 

 
{noformat}

[Pipeline] bbs_checkout
using credential [proper-credential-id]
> git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.repo.url https://localhost:8443/scm/project/repo.git # timeout=10
Fetching upstream changes from https://localhost:8443/scm/project/repo.git
> git.exe --version # timeout=10
using GIT_ASKPASS to set credentials Signon
> git.exe fetch --tags --force --progress -- https://localhost:8443/scm/project/repo.git +refs/heads/*:refs/remotes/repo/* # timeout=10
> git.exe rev-parse "repo/*master^{commit}" # timeout=10
> git.exe rev-parse "develop^{commit}" # timeout=10
[Pipeline] }
Posting build status of FAILED to Bitbucket ServerERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE{noformat}

Taking out the "${env.CREDENTIALS_ID}" and changing to something like 'hardcoded-credential-id' works.

This would work better if the payload configured in the Jenkins job could be injected as per issue JENKINS-60340 and not having to duplicate these values in the Jenkins job and in the Jenkinsfile.  We have different values for these based on different branches for access level information which is why we need to change the values around and not hard-code them in the Jenkinsfile.

bplump@atlassian.com (JIRA)

unread,
Mar 30, 2020, 12:19:02 AM3/30/20
to jenkinsc...@googlegroups.com
B Plump updated an issue
 
Change By: B Plump
Labels: tracked-by-atlassian
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages