Getting Started with CodeScene when Your Repositories Are in GitLab

Table of Contents

What is CodeScene?

CodeScene is an intelligent code analysis tool that helps teams improve code quality, reduce technical debt, and enhance development workflows. By integrating CodeScene with GitLab, teams can automatically analyze repositories, identify hotspots, and gain valuable insights to support decision-making.


Who Benefits From CodeScene with GitLab?

Stakeholders:

  • Developers: Identify troublesome code areas and receive actionable suggestions for improvements.

  • Engineering Managers: Monitor metrics to reduce risks and manage technical debt effectively.

  • CTOs & Tech Leads: Use insights to align technical efforts with business goals and better understand team dynamics.

  • DevOps Teams: Integrate with GitLab CI/CD pipelines for continuous quality assurance.


How to Enable CodeScene for GitLab

Install CodeScene

Run CodeScene in Docker 

docker run -d -it -p 3003:3003 \
--name codescene \
-v codescene:/codescene \
codescene/codescene

Once the container is running, access CodeScene at http://localhost:3003 for a local installation or at the server's url and log in with your license credentials.

  • Standalone Installation:
    Ensure Java 17+, Git, and SSH are installed. Run CodeScene as: 

    java -jar codescene.standalone.jar

    Access it via http://localhost:3003 for a local installation or at the server's url.

For Trial on-premise customers, we recommend using the script provided here when installing CodeScene

Authenticate CodeScene with GitLab

CodeScene can access your GitLab repositories through tokens or SSH keys.

Option A: Authenticate Using Personal Access Tokens (PAT)

  1. Create a PAT in GitLab with necessary permissions for repository data.

  2. Use this token in CodeScene's remote repository configuration phase.

Option B: Authenticate Using SSH Keys (Preferred)

  1. Generate an SSH key within the CodeScene container:

    docker exec -it -u codescene codescene ssh-keygen -q -t ed25519 -N '' -C "codescene" -f "/codescene/.ssh/id_ed25519"
  2. Display the public key:

    docker exec -it -u codescene codescene ssh-keygen -y -t ed25519 -f "/codescene/.ssh/id_ed25519"
  3. Add the SSH Key in GitLab:

    • Go to GitLab → Settings → SSH Keys.

    • Paste the public key.

  4. Test Access: 

    docker exec -it -u codescene codescene ssh -T git@gitlab.com

Add GitLab Repositories to CodeScene:

  • Login to CodeScene and create a new project.

  • Use Specify Remotes and input the SSH URL of your GitLab repository:

    git@gitlab.com:your-group/your-repo.git
  • CodeScene will clone and analyze the repository using the configured access credentials. 


Frequently Asked Questions

Q: Can CodeScene analyze both private and public GitLab repositories?
A: Yes, as long as SSH keys or tokens are set up correctly, CodeScene can access and analyze any GitLab repository.

Q: Is GitLab integration seamless with GitLab CI/CD?
A: Absolutely! CodeScene offers the necessary support to automate analyses within GitLab's pipelines.

Q: Are there provisions for GitLab on-premise?
A: Yes, the integration supports on-premise installations, making it adaptable to various organizational needs.

Q: How does CodeScene schedule analyses for large repositories?
A: CodeScene optimizes its analysis to focus on critical areas with high churn and complexity, ensuring efficiency even with large codebases.

Q: Will CodeScene need access to deployment logs?
A: No, CodeScene only requires access to the repositories for analysis, without needing deployment or runtime data.


Leverage the synergy of GitLab and CodeScene—improve code quality, optimize team collaboration, and drive strategic initiatives with comprehensive code insights. Explore automated processes and data-driven guidance for a more robust development lifecycle! 🚀