How do you view a log created during gitlab-runner exec?
I am testing a GitLab CI pipeline with
gitlab-runner exec. During a script, Boost ran into an error, and it created a log file. I want to view this log file, but I do not know how to.
.gitlab-ci.yml in project directory:
image: alpine variables: GIT_SUBMODULE_STRATEGY: recursive build: script: - apk add cmake - cd include/boost - sh bootstrap.sh
I test this on my machine with:
sudo gitlab-runner exec docker build --timeout 3600
The last several lines of the output:
Building Boost.Build engine with toolset ... Failed to build Boost.Build build engine Consult 'bootstrap.log' for more details ERROR: Job failed: exit code 1 FATAL: exit code 1
bootstrap.log is what I would like to view.
- cat bootstrap.log to
.gitlab-ci.yml does not output the file contents because the runner exits before this line. I tried looking though past containers with
sudo docker ps -a, but this does not show the one that GitLab Runner used. How can I open
See also questions close to this topic
How to Give A Postgres User SuperUser Previllege Through docker-compose?
This is my docker-compose file section for postgres container. These settings are fine, but my django app requires this user to have superuser previlleges through this command inside postgresql.
ALTER ROLE project_admin SUPERUSER;
How can this be accomodated inside this docker-compose file?
db: image: postgres:latest container_name: project-db environment: - POSTGRES_USER='project_admin' - POSTGRES_PASS='projectpass' - POSTGRES_DB='project'
/bin/sh: 1: sudo: not found when running dockerfile
RUN sudo apt-get update
RUN sudo apt-get install -y wget
CMD wget -O- -q http://ifconfig.me/ip
THis is the content of my dockerfile. When i am running the dockerfile to build a docker image, i get the below error:
/bin/sh: 1: sudo: not found
Can you please help me in solving the above error?
Error when trying to restore a SQL Server database on mac
I am trying to restore a SQL Server database on mac for the first time and I am following the tutorial. However, I have trouble creating a file under docker container as I enter this in the Terminal.
This is the first time I install a SQL Server 2017:
<mssql> sudo docker exec -it sql1 mkdir /var/opt/mssql/backup
I get an error:
Error: Incorrect syntax near '-'
How can I solve this problem?
git commits heatmap for a newly created project from an existing one
I pushed an existing git project to Gitlab and wanted to have an intuitive impression of git commits history through the Gitlab heatmap. Yet from the heatmap, I could only tell that I pushed to this repo that day and all the previous git commit history wouldn't reflect in the heatmap.
Is there a way to show my previous git commits in the heatmap? Or is the heatmap only to reflect the actions caused by
gitlab server timeout after configuring custom port
I have successfully installed gitlab and run it with embedded nginx. I have also successfully activated https. But when I try to change the external Url port (in both modes http and https) I get a time out error in my browser.
For information, I am running gitlab on a remote Ubuntu 18.04.2 server available from a registered domain and browsing with both Chrome and Safari from my computer from home.
I have reconfigured gitlab already a hundred times. I have checked the different involved ports to make sure they are allowed by firewall and listened to by the expected processes. Everything looks fine to me.
In /etc/gitlab/gitlab.rb I have done what described on the gitlab website for custom ports:
external_url 'http://gitlab.mydomain.com:10443' ... nginx['enable'] = true
When on standard port 80 and 443 I get the access logs in /var/log/gitlab/nginx/gitlab_access.log. But as soon as I have added the custom port I don't see anything anymore.
Result of the 'ufw status verbose' cmd:
Status: active Logging: on (low) Default: deny (incoming), allow (outgoing), disabled (routed) New profiles: skip To Action From -- ------ ---- ... 8080/tcp ALLOW IN Anywhere 10443/tcp ALLOW IN Anywhere ... 8080/tcp (v6) ALLOW IN Anywhere (v6) 10443/tcp (v6) ALLOW IN Anywhere (v6)
Result of the 'netstat -tulpn' cmd:
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 14865/unicorn maste tcp 0 0 0.0.0.0:10443 0.0.0.0:* LISTEN 21422/nginx: master tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 21422/nginx: master
What is even weird is that when I perform cmd 'nc -vz gitlab.mydomain.com 10443', it succeeds:
Connection to gitlab.mydomain.com 10443 port [tcp/*] succeeded!
The request to http://gitlab.mydomain.com:10443 (or its SSL version when activated) ends up with a ERR_CONNECTION_TIMED_OUT on Chrome and 'Safari can't open the page "gitlab.mydomain.com:10443" because the server where this page is located isn't responding' on Safari.
minimize git diff by undoing trivial changes
When working with code (mostly c++ in my case) and specifically with git and gitlab, I often find myself working on a specific merge request and feature addition for several weeks. At the end, I arrive with a very long merge request that is very hard for the maintainers to understand, because I have committed a lot of changes.
Some of these changes are intentional and important to the feature at hand, others are trivial like fixing the indentation of a certain section of code, which I often to to improve readability while I'm debugging. However, in order for the MR to be as small as readable as possible, I'd like to "undo" all the trivial changes not affecting the code itself (but only the layout) before removing the WIP label from my MR. So I sometimes find myself going through my MR and undoing all those prettifications by hand in order to make the MR more readable for the reviewers.
This is a lot of stupid work that could be spent better elswhere.
Is there a script or mechanism that I can use (specifically on c++ code) to go through the code and undo all trivial changes (for example, whitespace changes) with respect to a certain commit? This would simplify my life significantly. I could see myself writing a script for this, but I'm hoping for there to be some git magic that I can use, or for someone else already having solved this issue for me. Any suggestions?
How do I add a timer to my gitlab-ci job to make it stop within 1 minute in gitlab-ci.yml
I have a spring boot application and I am configuring gitlab-ci.yml to run my integration tests. In order to achieve that I need my spring boot app running.
I am able to bring up my app using spring-boot-maven-plugin but the job I configured does not complete since the app is running and times out at 1 hour.
Is there a way to end a gitlab-ci job after a minute or two?
here is my gitlab-ci.yml config
server_start: stage: test script: - mvn spring-boot:start
Are there other examples of how to configure the gitlab-ci.yml to check if the server is up?
GitLab CI get last artifact
I'm trying to get the latest build artifact using
curl. Here's what I've tried.
First, get last pipeline id:
curl -v -H "Content-Type: application/json" -H "PRIVATE-TOKEN: <my-token-here>" https://<project>/api/v4/projects/<project>/pipelines?per_page=1&page=1
Next, get job id based on pipeline id just obtained before:
curl -sS --header "PRIVATE-TOKEN: <my-token-here>" "https://[redacted,host]/api/v4/projects/[redacted,project]/pipelines/<pipeline-id>/jobs" | jq '. | select(.name == "build-assets" and .status == "success" and .artifacts_file != null) | .id'
Finally, get the artifacts to
build.zipbased on job id:
curl -sS --header "PRIVATE-TOKEN: <my-token-here>" "https://[redacted,host]/api/v4/projects/[redacted, project]/jobs/<JOB_ID>/artifacts" > build.zip
These steps above do work, but I have to hit three endpoints (and process the JSON response for each step).
I also read in GitLab's documentation, that there's a single endpoint available for this. So I also tried this:
curl -sS --header "PRIVATE-TOKEN: <my-token-here>" "https://<url>/<namespace>/<project>/-/jobs/artifacts/<refs>/download?job=<job_name>"
but this always redirects me to the login page, saying this:
<html><body>You are being <a href="https://<url>/users/sign_in">redirected</a>.</body></html>
Is there any simpler way to do this task? Or how to use the endpoint that is described on the documentation above propeprly?
Execute external bash script inside GitLab-ci Docker build
I would like to execute an external (on the local machine) bash script from gitlab-ci.yml which uses the docker:stable image. I would like to execute startup.sh located outside the gitlab docker image. Is this possible or are there better options?
image: docker:stable #Build script variables: CI_DEBUG_TRACE: "true" DOCKER_DRIVER: overlay before_script: - docker --version build: services: - docker:dind script: - docker build --no-cache -t <tag> . - docker login -u root -p <pass> <registry> - docker tag ... - docker push ... - echo "build completed" stage: build tags: - <tag> deploy_staging: stage: deploy script: - ./sh startup.sh
#!/bin/bash docker login -u root -p <pass> docker pull <image> docker-compose up -d