3

I am new to gitlab runners and trying to automate my project so that whenever a new tag is released, it should build a new deb package. PS: I am using mac and following this official link by gitlab to get my task done

My first gitlab-ci.yml file was(which is just given there on the official link of gitlab I provided above):

# Is performed before the scripts in the stages step before_script: - source /etc/profile # Defines stages which are to be executed stages: - build # Stage "build" run-build: stage: build script: - apt-get install -y libncurses5-dev libglib2.0-dev libgeoip-dev libtokyocabinet-dev zlib1g-dev libncursesw5-dev libbz2-dev - autoreconf -fvi - cp COPYING debian/copyright - dpkg-buildpackage -us -uc - mkdir build - mv ../goaccess*.deb build/ # This stage is only executed for new tags only: - tags # The files which are to be made available in GitLab artifacts: paths: - build/* 

The problem I initially getting with the above gitlab-ci.yml file was:

Output 1:

Fetching changes with git depth set to 20... Reinitialized existing Git repository in /home/gitlab-runner/builds/GJ7z2Aym/0/edge_release_management/.git/ Checking out 3d71402b as tag1-test... Skipping Git submodules setup Executing "step_script" stage of the job script 00:00 $ source /etc/profile $ apt-get install -y libncurses5-dev libglib2.0-dev libgeoip-dev libtokyocabinet-dev zlib1g-dev libncursesw5-dev libbz2-dev E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root? Cleaning up project directory and file based variables 00:00 ERROR: Job failed: exit status 1 

which says E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

So to resolve the above issue, I thought to change the brefore_script part with this

# Is performed before the scripts in the stages step before_script: - source /etc/profile - echo "Hello, $GITLAB_USER_LOGIN!" - echo "Hello, $GITLAB_USER_PASSWORD" # - sudo rm /var/cache/apt/archives/lock # - sudo rm /var/lib/dpkg/lock - sudo su 

Where I am trying to remove /var/cache/apt/archives/lock and /var/lib/dpkg/lock, as this is what I found on Google. When it didn't work, I tried sudo su. But with the above change, I started to get this issue.

Output 2:

Getting source from Git repository 00:00 Fetching changes with git depth set to 20... Reinitialized existing Git repository in /home/gitlab-runner/builds/GJ7z2Aym/0/edge_release_management/.git/ Checking out 7fbaaf4f as testing4... Skipping Git submodules setup Executing "step_script" stage of the job script 00:00 $ source /etc/profile $ sudo rm /var/cache/apt/archives/lock sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Cleaning up project directory and file based variables 00:00 ERROR: Job failed: exit status 1 

It says sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required

So, to resolve this, I used sudo -S su < $password_secret as shown:

# Is performed before the scripts in the stages step before_script: - source /etc/profile - echo "Hello, $GITLAB_USER_LOGIN!" - echo "Hello, $GITLAB_USER_PASSWORD" # - sudo rm /var/cache/apt/archives/lock # - sudo rm /var/lib/dpkg/lock # - sudo su - sudo -S su < $password_secret 

Please note: I have saved $password_secret in Gitlab variables and it's value is $password.secret as someone on google said this can be it's value. I am not sure how true it is.

And now it is giving me this error: Output 3:

Fetching changes with git depth set to 20... Reinitialized existing Git repository in /home/gitlab-runner/builds/GJ7z2Aym/0/edge_release_management/.git/ Checking out 0b8ab538 as 26... Skipping Git submodules setup Executing "step_script" stage of the job script 00:02 $ source /etc/profile $ echo "Hello, $GITLAB_USER_LOGIN!" Hello, user! $ echo "Hello, $GITLAB_USER_PASSWORD" Hello, $ sudo -S su < $password_secret [sudo] password for gitlab-runner: Sorry, try again. [sudo] password for gitlab-runner: sudo: no password was provided sudo: 1 incorrect password attempt Cleaning up project directory and file based variables 00:00 ERROR: Job failed: exit status 1 

Please note: I have also used the way which is mentioned here

But, I found that usermod is not there for macOS. So I tried using another way which is mentioned here using dscl. But it still showing me the Output 3 only

Now I am fed up and unable to think of any other possible ways to fix this. I think I have tried almost everything released to this issue(which might not be true at all, as there must be some solution for this, I believe). Can anyone please help me with this?

Summary: Basically my main problem is shown in the first output which says E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?. Rest everything I am doing is to resolve it only.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.