GithubHelp home page GithubHelp logo

Comments (6)

NahidSiddiqui avatar NahidSiddiqui commented on August 31, 2024 4

I am using pipeline and was wondering how I can trigger off builds from multibranch pipeline project but some reason I cannot get the value for CHANGE_ID for a branch that has a pending pull request active. I use a Jenkins file that is stored in the repo and I was looking to trigger off builds using the code in the Jenkins file which needs to detect the pull request using CHANGE_ID. I tried using sh " echo env.CHANGE_ID" but this returns null. However I do get a value for sh "echo env.BRANCH_NAME".

from percy-client.

fotinakis avatar fotinakis commented on August 31, 2024

Hey @jonesetc — thanks for this info, very helpful.

Before we update this and our other client libraries to natively support it, can you use our override variables to make sure things work in your Pipeline Plugin environment?

export PERCY_PULL_REQUEST="$CHANGE_ID"
export PERCY_BRANCH ="$BRANCH_NAME"

If the commit SHA is no longer stored in GIT_COMMIT, you'll also need to export PERCY_COMMIT="$SOME_PIPELINE_ENV_VAR_FOR_COMMIT_SHA"

If that works for you, we can update our libraries to check if Pipeline is used vs. GHPRB.

from percy-client.

jonesetc avatar jonesetc commented on August 31, 2024

Thanks for the quick response.

Setting PERCY_BRANCH to $BRANCH_NAME works and is what we started doing to work around our issue of master builds not being recognized as such. I will do a little bit of testing to set those other two variables and make sure.

I'm guessing that if PERCY_PULL_REQUEST is set correctly, the UI for the build will have a link back to that PR?

from percy-client.

fotinakis avatar fotinakis commented on August 31, 2024

Yup!

from percy-client.

jonesetc avatar jonesetc commented on August 31, 2024

So, I did a little bit of testing, and here's the general information:

  • BRANCH_NAME is a replacement for ghprbTargetBranch, and is always available
  • CHANGE_ID is a replacement for ghprbPullId, but is not always available
    • The Pipeline Plugin can be configured to build all branches, not just PRs, and as such does not usually have this set on the env
  • There is no available variable that serves the same information as GIT_COMMIT, so it would require the fallback to parsing raw git output
    • The Pipeline Plugin is built abstractly from all SCM systems, so specific things like commits are not available in the environment
    • The commit hash is available elsewhere to the user, but would still require the user to manually set it on the environment

I'd be happy to make a PR for this that would basically:

  • Add a new current_ci tag called :jenkins-pipeline
  • _commit_sha would still fall through and use the _raw_commit_output('HEAD')
  • branch would use ENV['BRANCH_NAME']
  • pull_request_number would use ENV['CHANGE_ID'] if available

from percy-client.

fotinakis avatar fotinakis commented on August 31, 2024

👍 Sounds good to us, @jonesetc! Thanks for doing that research as well.

from percy-client.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.