I want to use C shell and Perl script in Gitlab CI/CD pipeline.
- There are many design assets written in C shell and Perl.
Looking at the following materials, I don’t think it supports C shell or Perl, but is it possible to execute it?
If not possible, is there any workaround?
I am using gitlab-runner version .16.2.0.
However registers a new runner towards the GitLab instance you host your code on, can specify
--shell (the help text in
gitlab-runner register says ‘Select bash, sh, cmd, pwsh or powershell’) when registering a shell runner, if it’s a image based runner (e.g. docker), select an image that has what you need.
I haven’t used C shell since the late 90’s (it was the default on the unix servers at the maths institute) so I have very little experience, but I would guess it can be used like most other scripting languages, and if an interpreter is installed you can execute them as anything else, we have plenty of scripts written in either perl or python and we execute those from
.gitlab-ci.yml (or from each other) just like we execute anything else.
Thank you for answering. Is my understanding as below correct?
・C shell and Perl script cannot be used unless a image based runner (e.g. docker) is specified.
・If I use a C shell and Perl script, I have to use an image based runner (e.g. docker).
I can run C shell and Perl scripts in the terminal of my Linux machine where I installed gitlab-runner, so I don’t understand why gitlab-runner can’t run C shell and Perl scripts. Will gitlab-runner run in its own terminal?
No. Your understanding is not correct!
You can execute Perl (and I guess C shell, but as I said, I have no non-ancient experience with that) in any runner, as long as it’s on the machine the job get run on.
What I said about image based runners was that using those you can make a C shell/Perl (I believe there exists some shell that understand (a little) Perl) interface the default.
I have no idea what you mean by “in its own terminal”. The runner does do something to collect output from executed jobs, I actually don’t know if that makes the jobs think they have been executed from a terminal (it is possible to check), but in general you should assume that jobs have no attached terminal.
If a tool is available on the machine the jobs run on, they can use that tool, and that tool may be
perl or anything else.
Thank you for answering. understood.
However, I cannot execute C shell commands as I expected. Can you guess what’s causing this?
Here is an example of running a C shell command in a gitlab-runner job.
“setenv” is a C shell command that sets environment variables and works fine on the machine where gitlab-runner is run.
$ setenv XXX_HOME /cad/XXX/HOME/bin
bash: setenv: command not found
You can execute C shell/Perl in jobs, you can’t use it to write your jobs (unless if the runner is registered with the
--shell option I talked about in my first post, and csh is actaully supported by it, as I said the documentation lists five different options).
Each line you put in the project’s
.gitlab-ci.yml (I assume the lines you show is a cut from there) is executed on it’s own by
bash (or whatever shell the runner is configured to use), even if you used the bash syntax
export XXX_HOME=/cad/XXX/HOME/bin, that variable probably wouldn’t be accessible from the commands run subsequently. (But I am not sure I’ve actually tried). What you can do (and all that I intended to suggest above) is write a script in C Shell or Perl (i.e. one that begins with
#! /usr/bin/perl or is invoked properly) and call that, inside that you can do pretty much anything that language allows.
Thank you for answering. understood.
When I executed a C shell command inside a job written in bash, it worked without any problems.Also, as you pointed out, the environment variables set with the export command were not carried over to subsequent processing.I create pipelines with care.