Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 7072

Pipeline fails to change php version

$
0
0

I am having issues with a pipeline failing because it is not setting the correct version of PHP which then causes a composer install to fail but when manually running the same commands and checking php version the correct version is set.

The pipeline is setup as follows:

# PHP# Test and package your PHP project.# Add steps that run tests, save build artifacts, deploy, and more:# https://docs.microsoft.com/azure/devops/pipelines/languages/phptrigger:- masterpool:  vmImage: ubuntu-latestvariables:  phpVersion: 7.4steps:- script: |    sudo update-alternatives --set php /usr/bin/php$(phpVersion)    sudo update-alternatives --set phar /usr/bin/phar$(phpVersion)    sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion)    sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion)    sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion)    php -version  displayName: 'Use PHP version $(phpVersion)'- script: composer install --no-interaction --prefer-dist  displayName: 'composer install'- task: ArchiveFiles@2  inputs:    rootFolderOrFile: '$(system.defaultWorkingDirectory)'    includeRootFolder: false- task: PublishBuildArtifacts@1

the failed job log shows as follows

Starting: Use PHP version 7.4==============================================================================Task         : Command lineDescription  : Run a command line script using Bash on Linux and macOS and cmd.exe on WindowsVersion      : 2.212.0Author       : Microsoft CorporationHelp         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line==============================================================================Generating script.========================== Starting Command Output ===========================/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/7743b650-1902-47f9-ae80-b9ee9186f3bb.shupdate-alternatives: error: alternative /usr/bin/php7.4 for php not registered; not settingupdate-alternatives: error: alternative /usr/bin/phar7.4 for phar not registered; not settingupdate-alternatives: error: alternative /usr/bin/phpdbg7.4 for phpdbg not registered; not settingupdate-alternatives: error: alternative /usr/bin/php-cgi7.4 for php-cgi not registered; not settingupdate-alternatives: error: alternative /usr/bin/phar.phar7.4 for phar.phar not registered; not settingPHP 8.1.2-1ubuntu2.11 (cli) (built: Feb 22 2023 22:56:18) (NTS)Copyright (c) The PHP GroupZend Engine v4.1.2, Copyright (c) Zend Technologies    with Zend OPcache v8.1.2-1ubuntu2.11, Copyright (c), by Zend Technologies    with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick RethansFinishing: Use PHP version 7.4

previously this pipeline has worked and the log showed:

Starting: Use PHP version 7.4==============================================================================Task         : Command lineDescription  : Run a command line script using Bash on Linux and macOS and cmd.exe on WindowsVersion      : 2.212.0Author       : Microsoft CorporationHelp         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line==============================================================================Generating script.========================== Starting Command Output ===========================/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/2a36edba-2975-4d4b-906d-f1e2f0e869a7.shupdate-alternatives: using /usr/bin/php7.4 to provide /usr/bin/php (php) in manual modeupdate-alternatives: using /usr/bin/phar7.4 to provide /usr/bin/phar (phar) in manual modeupdate-alternatives: using /usr/bin/phpdbg7.4 to provide /usr/bin/phpdbg (phpdbg) in manual modeupdate-alternatives: using /usr/bin/php-cgi7.4 to provide /usr/bin/php-cgi (php-cgi) in manual modeupdate-alternatives: using /usr/bin/phar.phar7.4 to provide /usr/bin/phar.phar (phar.phar) in manual modePHP 7.4.33 (cli) (built: Nov  8 2022 11:33:35) ( NTS )Copyright (c) The PHP GroupZend Engine v3.4.0, Copyright (c) Zend Technologies    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies    with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick RethansFinishing: Use PHP version 7.4

I have manually run the following commands to update alternatives and set the php version on my ubuntu server:

sudo update-alternatives --set php /usr/bin/php7.4sudo update-alternatives --set phar /usr/bin/phar7.4sudo update-alternatives --set phpdbg /usr/bin/phpdbg7.4sudo update-alternatives --set php-cgi /usr/bin/php-cgi7.4sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.4php -version

which outputs the following:

user@server:~$ sudo update-alternatives --set php /usr/bin/php7.4user@server:~$ sudo update-alternatives --set phar /usr/bin/phar7.4user@server:~$ sudo update-alternatives --set phpdbg /usr/bin/phpdbg7.4update-alternatives: error: alternative /usr/bin/phpdbg7.4 for phpdbg not registered; not settinguser@server:~$ sudo update-alternatives --set php-cgi /usr/bin/php-cgi7.4user@server:~$ sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.4user@server:~$ php -versionPHP 7.4.33 (cli) (built: Jun  8 2023 15:22:42) ( NTS )Copyright (c) The PHP GroupZend Engine v3.4.0, Copyright (c) Zend Technologies    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

So it appears I can manually change the version of PHP but the pipeline is failing to do so. Any help resolving this issue would be greatly appreciated, thanks!

I have tried manually setting the php version


Viewing all articles
Browse latest Browse all 7072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>