How to run this via Gitlab CI/CD using docker executor runner
Hello. I am quite new at docker. I have previously used some docker images. Normally, I run the docker image using --it flag which allows me to wander inside the docker container and see what is going on there. See example of interactive mode that I use for another docker image:
patrikas@xxx-xxx:/tmp/test-tool-binaries$ sudo docker run -it --rm=true xanderhendriks/stm32cubeide:7.0
root@93c40c788d73:/# ls
bin boot dev etc home lib lib32 lib64 libx32 media mnt opt proc root run sbin srv sys tmp usr var
root@93c40c788d73:/#
I have noticed that amake/innosetup docker image does not allow that. For some reason it automatically kicks me out of the docker container after it is run:
patrikas@xxx-xxx:/tmp/test-tool-binaries$ sudo docker run --rm -it -v $PWD:/work amake/innosetup
Inno Setup 6 Command-Line Compiler
Copyright (C) 1997-2024 Jordan Russell. All rights reserved.
Portions Copyright (C) 2000-2024 Martijn Laan. All rights reserved.
Portions Copyright (C) 2001-2004 Alex Yackimoff. All rights reserved.
https://www.innosetup.com
Usage: iscc [options] scriptfile.iss
or to read from standard input: iscc [options] -
Options:
/O(+|-) Enable or disable output (overrides Output)
/O<path> Output files to specified path (overrides OutputDir)
/F<filename> Overrides OutputBaseFilename with the specified filename
/S<name>=<command> Sets a SignTool with the specified name and command
/Q Quiet compile (print error messages only)
/Qp Enable quiet compile while still displaying progress
/D<name>[=<value>] Emulate #define public <name> <value>
/$<letter>(+|-) Emulate #pragma option -<letter>(+|-)
/P<letter>(+|-) Emulate #pragma parseroption -<letter>(+|-)
/I<paths> Emulate #pragma include <paths>
/J<filename> Emulate #include <filename>
/{#<string> Emulate #pragma inlinestart <string>
/}<string> Emulate #pragma inlineend <string>
/V<number> Emulate #pragma verboselevel <number>
/? Show this help screen
Example: iscc /$c- /Pu+ "/DLic=Trial Lic.txt" /IC:\INC;D:\INC scriptfile.iss
patrikas@xxx-xxx:/tmp/test-tool-binaries$
I have found a way how to generate a setup if I run the docker via my server VM:
patrikas@xxx-xxx:/tmp/test-tool-binaries$ sudo docker run --rm -it -v $PWD:/work amake/innosetup Install/Create_install.iss
Inno Setup 6 Command-Line Compiler
Copyright (C) 1997-2024 Jordan Russell. All rights reserved.
Portions Copyright (C) 2000-2024 Martijn Laan. All rights reserved.
Portions Copyright (C) 2001-2004 Alex Yackimoff. All rights reserved.
https://www.innosetup.com
Compiler engine version: Inno Setup 6.3.1
Preprocessing
Reading file: C:\Program Files\Inno Setup 6\ISPPBuiltins.iss
Parsing [Setup] section, line 6
Parsing [Setup] section, line 7
Parsing [Setup] section, line 8
Parsing [Setup] section, line 9
Parsing [Setup] section, line 10
Parsing [Setup] section, line 11
Parsing [Setup] section, line 12
Parsing [Setup] section, line 13
Parsing [Setup] section, line 14
Parsing [Setup] section, line 15
Parsing [Setup] section, line 16
Parsing [Setup] section, line 17
Parsing [Setup] section, line 18
Reading file (WizardImageFile)
Reading file (WizardSmallImageFile)
Preparing Setup program executable
Updating version info (SETUP.E32)
Determining language code pages
Reading file: C:\Program Files\Inno Setup 6\Default.isl
Messages in script file
Reading default messages from Default.isl
Parsing [LangOptions], [Messages], and [CustomMessages] sections
Reading file: C:\Program Files\Inno Setup 6\Default.isl
Messages in script file
...
...
...
...
I am now trying to find a way how to generate setup using Gitlab CI/CD. I tried to use docker executor but since it does not have interactive mode I dont think this is possible? I tried the following CI/CD script:
build_job:
image: amake/innosetup
variables:
GIT_SUBMODULE_STRATEGY: normal
rules:
- if: $CI_COMMIT_TAG # Run this job when a tag is created
stage: build
script:
- echo "Preparing to generate setup"
- ls -l
- cd Install
- ls -l
- iscc Create_install.iss
But I get the following error:
Running with gitlab-runner 16.6.1 (f5da3c5a)
on (GENERIC) Runner for UTB_V4 project KtvN1TZp[2](https://xxx-xxx.test.lt/kontraktine/test-tool-binaries/-/jobs/1159#L2), system ID: s_1de69ef528ed
Preparing the "docker" executor
00:03
Using Docker executor with image amake/innosetup ...
Pulling docker image amake/innosetup ...
Using docker image sha256:c1669a82a7d75c9f8d4effeb69e754679f98295816c[3](https://xxx-xxx.test.lt/kontraktine/test-tool-binaries/-/jobs/1159#L3)cd4e96a895db06aeae8d for amake/innosetup with digest amake/innosetup@sha256:097219cb73958af1f0e73606f[4](https://xxx-xxx.test.lt/kontraktine/test-tool-binaries/-/jobs/1159#L4)de2ce67c4f04dfcedd14e675830ae111affd15 ...
Preparing environment
00:01
Running on runner-ktvn1tzp2-project-102-concurrent-0 via xxx-xxx...
Getting source from Git repository
00:01
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/kontraktine/test-tool-binaries/.git/
Checking out 2363010d as detached HEAD (ref is 1.0.4)...
Removing JOB_ID.txt
Removing release_notes.md
Removing version.txt
Updating/initializing submodules with git depth set to 20...
Updated submodules
Downloading artifacts
00:01
Downloading artifacts for prepare_job (11[5](https://xxx-xxx.test.lt/kontraktine/test-tool-binaries/-/jobs/1159#L5)8)...
Downloading artifacts from coordinator... ok host=xxx-xxx.test.lt id=1158 responseStatus=200 OK token=glcbt-[6](https://xxx-xxx.test.lt/kontraktine/test-tool-binaries/-/jobs/1159#L6)4
Executing "step_script" stage of the job script
00:06
Using docker image sha256:c1669a82a7d75c9f8d4effeb69e754679f98295816c3cd4e96a895db06aeae8d for amake/innosetup with digest amake/innosetup@sha256:097219cb73958af1f0e[7](https://xxx-xxx.test.lt/kontraktine/test-tool-binaries/-/jobs/1159#L7)3606f4de2ce67c4f04dfcedd14e675[8](https://xxx-xxx.test.lt/kontraktine/test-tool-binaries/-/jobs/1159#L8)30ae111affd15 ...
Inno Setup 6 Command-Line Compiler
Copyright (C) 1[9](https://xxx-xxx.test.lt/kontraktine/test-tool-binaries/-/jobs/1159#L9)97-2024 Jordan Russell. All rights reserved.
Portions Copyright (C) 2000-2024 Martijn Laan. All rights reserved.
Portions Copyright (C) 2001-2004 Alex Yackimoff. All rights reserved.
https://www.innosetup.com
Unknown option: -c
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
I would very much appreciate if someone could shed some light on how I can use this docker image with gitlab-runner with docker executor to generate setup for my project.
Normally, I run the docker image using --it flag which allows me to wander inside the docker container and see what is going on there
The entrypoint of such an image is probably set to be a shell of some sort. The entrypoint of amake/innosetup is the InnoSetup executable (iscc); thus the result of docker run is the same as running iscc without any arguments—it prints the help text.
If you want to run a shell, specify the entrypoint to be e.g. /bin/bash with the --entrypoint flag:
% docker run -it --rm --entrypoint /bin/bash amake/innosetup
xclient@8c35f8675f70:/work$
I tried to use docker executor but since it does not have interactive mode I dont think this is possible?
I've never used a Docker image in CI in "interactive mode". I think you are barking up the wrong tree.
I don't know anything about Gitlab's CI so I can't give any specific advice, but I don't think you wan to run your job/task "in" amake/innosetup; in other words you shouldn't specify amake/innosetup for your job's image. You want to run docker run --rm -i -v $PWD:/work amake/innosetup work/Create_install.iss as part of a script executed by your job.
Thanks for some useful insights. Using docker executor in gitlab-runner only works if the default entrypoint is a shell.
For this particular case, since it is not a shell, I have changed to shell executor for my gitlab-runner meaning it will simply start a shell on the VM where the Gitlab-runner is installed.
build_job:
variables:
GIT_SUBMODULE_STRATEGY: normal
rules:
- if: $CI_COMMIT_TAG # Run this job when a tag is created
tags:
- shell
allow_failure: true
stage: build
script:
- echo "Preparing to generate setup"
- ls -l
- ls -l Install
- id
- chmod -R 777 Install
- docker run --rm -i -v $PWD:/work amake/innosetup Install/Create_install.iss
The above seems to work and generate a setup for my application. I also had to make sure gitlab-runner is added to docker group to ensure it has privilleges to run docker command:
sudo usermod -aG docker gitlab-runner
Hope this is helpful for someone else :)
Although there is still one issue:
When a directory Install_executables is created during the CI/CD setup creation process, I can see that it is has the following permissions:
$ ls -l Install
total 12
-rwxrwxrwx 1 gitlab-runner gitlab-runner 4422 Jun 28 16:03 Create_install.iss
drwxr-xr-x 2 administrator systemd-journal 4096 Jun 28 16:03 Install_executables
So when I try to run a JOB for a second time, it fails the clean up old job artifacts:
Running with gitlab-runner 16.6.1 (f5da3c5a)
on generic shell KbZwcgsRr, system ID: s_1de69ef5[2](https://xxx-xxx.test.lt/kontraktine/test-tool-binaries/-/jobs/1242#L2)8ed
Preparing the "shell" executor
00:00
Using Shell (bash) executor...
Preparing environment
00:00
Running on xxx-xxx...
Getting source from Git repository
00:0[3](https://xxx-xxx.test.lt/kontraktine/test-tool-binaries/-/jobs/1242#L3)
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /home/gitlab-runner/builds/KbZwcgsRr/0/kontraktine/test-tool-binaries/.git/
Checking out 8[4](https://xxx-xxx.test.lt/kontraktine/test-tool-binaries/-/jobs/1242#L4)8ea069 as detached HEAD (ref is 1.0.1)...
warning: failed to remove Install/Install_executables/ODM026_TestTool_3.0.1.0_Config_0.0.0.1_setup.exe: Permission denied
Removing JOB_ID.txt
Removing release_notes.md
Uploading artifacts for failed job
00:00
Uploading artifacts...
Runtime platform arch=amd64 os=linux pid=64381 revision=f[5](https://xxx-xxx.test.lt/kontraktine/test-tool-binaries/-/jobs/1242#L5)da3c5a version=16.6.1
WARNING: JOB_ID.txt: no matching files. Ensure that the artifact path is relative to the working directory (/home/gitlab-runner/builds/KbZwcgsRr/0/kontraktine/test-tool-binaries)
ERROR: No files to upload
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1
I am now trying to understand whether that is an issue from the gitlab-runner or the Create_install.iss side.
Had the Same Issue and Fixed it – Here is my Pipeline:
You have to clear the entrypoint with:
image:
name: amake/innosetup
entrypoint: [""]
Then you can use iscc myscript.iss to start Inno Setup.
Full Stage:
innosetup:
stage: package
image:
name: amake/innosetup
entrypoint: [""]
tags:
- innosetup
script:
- mkdir -p ./Output
- echo "Current directory $(pwd)"
- echo "Contents of directory:"
- ls -la
- echo "Checking if myscript.iss exists..."
- if [ ! -f myscript.iss ]; then echo "myscript.iss not found!"; exit 1; fi
- iscc myscript.iss
dependencies:
- sign
artifacts:
paths:
- ./Output/
Censored Pipeline Output
Running with gitlab-runner 17.1.0 (fe451d5a)
on my-gitlabrunner **********, system ID: **********
Preparing the "docker" executor
00:02
Using Docker executor with image amake/innosetup ...
Pulling docker image amake/innosetup ...
Using docker image sha256:********** for amake/innosetup with digest amake/innosetup@sha256:********** ...
Preparing environment
00:01
Running on runner-**********-project-***-concurrent-0 via my-gitlabrunner...
Getting source from Git repository
00:01
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/**********/**********/**********/.git/
Checking out ********** as detached HEAD (ref is main)...
Removing codeSignCert.pfx
Removing publish/
Skipping Git submodules setup
Downloading artifacts
00:01
Downloading artifacts for sign (****)...
Downloading artifacts from coordinator... ok host=********** id=**** responseStatus=200 OK token=**********
Executing "step_script" stage of the job script
00:10
Using docker image sha256:********** for amake/innosetup with digest amake/innosetup@sha256:********** ...
$ mkdir -p ./Output
$ if [ ! -f myscript.iss ]; then echo "myscript.iss not found!"; exit 1; fi
$ iscc myscript.iss
Inno Setup 6 Command-Line Compiler
Copyright (C) 1997-2024 Jordan Russell. All rights reserved.
Portions Copyright (C) 2000-2024 Martijn Laan. All rights reserved.
Portions Copyright (C) 2001-2004 Alex Yackimoff. All rights reserved.
https://www.innosetup.com
Compiler engine version: Inno Setup 6.3.3
Preprocessing
Reading file: C:\Program Files\Inno Setup 6\ISPPBuiltins.iss
Parsing [Setup] section, line 2
Parsing [Setup] section, line 3
Parsing [Setup] section, line 4
Parsing [Setup] section, line 5
Parsing [Setup] section, line 6
Parsing [Setup] section, line 7
Parsing [Setup] section, line 8
Reading file (WizardImageFile)
Reading file (WizardSmallImageFile)
Preparing Setup program executable
Updating version info (SETUP.E32)
Determining language code pages
Reading file: C:\Program Files\Inno Setup 6\Default.isl
Messages in script file
Reading default messages from Default.isl
Parsing [LangOptions], [Messages], and [CustomMessages] sections
Reading file: C:\Program Files\Inno Setup 6\Default.isl
Messages in script file
Reading [Code] section
Parsing [Icons] section, line 14
Parsing [Files] section, line 11
Creating setup files
Compressing: **********\**********\**********\publish\my-csharp-service.exe
Compressing Setup program executable
Updating version info (SETUP.EXE)
Updating manifest (SETUP.EXE)
Warning: Constant "pf" has been renamed. Use "commonpf" instead or consider using its "auto" form.
Successful compile (1.945 sec). Resulting Setup program filename is:
**********\**********\**********\Output\MyProgramSetup.exe
Uploading artifacts for successful job
00:01
Uploading artifacts...
./Output/: found 2 matching artifact files and directories
Uploading artifacts as "archive" to coordinator... 201 Created id=**** responseStatus=201 Created token=**********
Cleaning up project directory and file based variables
00:00
Job succeeded