Textile industry and labor sources yesterday confirmed the existence of an unwritten "agreement in principle" that could end the 17-year war between J.P. Stevens & Co. and the Amalgamated Clothing and Textile Workers union.

Industry sources bluntly warned, however, that the agreement may be scuttled because of what they called "a very dangerous publicity game" allegedly being played by the union.

The publicity problem amounts to this: After nearly two decades of fighting that has cost both sides millions of dollars and frequent embarrassment, both sides want a settlement but neither wants to be declared a loser.

Some industry sources are calling the agreement a "sweetheart deal" that easily could be abandoned "if the union tries to present it as a victory."

Labor sources, on the other hand, have described the agreement as a "breakthrough" for union organizing in the South where Stevens, the nation's second-largest textile manufacturer with annual sales of $1.833 billion, has most of its 80 plants.

Neither ACTWU nor Stevens officials are saying anything for the record at this point. Indeed, in almost identical words, both the company and the union are saying "there is no imminent agreement." Background information on the potential accord is coming mostly from "labor sources" and "industry sources" who are "close to the negotiations."

Industry sources interviewed yesterday presented this picture:

Nothing is in writing. Nothing has been signed.

The company is willing to sign a contract with the ACTWU if the union drops its four-year national boycott of J.P. Stevens products and abandons all publicity campaigns designed to hurt the Stevens image.

The contract would cover seven Stevens plants in Roanoke Rapids, N.C., affecting 2,500 employes; a Stevens facility in High Point, N.C., affecting about 100 workers; and a Stevens plant in Allendale, S.C., also affecting about 100 employes.

The company does not and will not shut down plants to avoid unionization. However, the company will use all legal means possible to prevent the organization of its other 71 nonunion plants.

"The company isn't giving the union one goddamned thing more than it was offered in 1974" when it won its first representational election at Roanoke Rapids, according to an industry source.

Labor sources said yesterday that the agreement, as it now stands, is verbal. It would cover the plants described by the industry sources (although one labor source said the agreement also would cover a Stevens facility in West Boylston, Ala.).

The agreement would include a dues checkoff for ACTWU members, something the company has resisted vigorously n the past, labor sources said.

The agreement also would include an employe grievance procedure that the company has opposed and would end the union's boycott of Stevens when the contract is signed.

"Basically, what there is now is a middle-of-the road agreement that the two sides are trying to make sound like some kind of a victory," one labor source said.

Like two weary maneuvering armies, both company and union forces are trying to gain as much final ground as possible in view of the expected treaty. The union, carrying out its vow to continue attacking Stevens until there is a settlement, struck again Tuesday in New York City in an attempt to prevent James D. Finley, chairman of the Stevens executive committee, from retaining his seat on the board of directors of Sperry Corp.

ACTWU was beaten badly, as Finley won re-election to an 11th term on the Sperry board with about 94 percent of the 30.4 million shares voted at the meeting.

But if the ACTWU wanted to irritate Stevens with the New York action, it succeeded.

Company officials were seething yesterday, according to one industry source who said: "They (the ACTWU) are terrorists . . . . There is attached to the meetings and agreements between us at this point a fragility that was all but destroyed by the Sperry episode, and by union news leaks of a 'settlement' in which the union is claiming victory."

Stevens currently pays its textile workers -- excluding those at Roanoke Rapids -- an average hourly salary of about $5.13, the industry spokesman said. "That is about 6.7 percent higher than the $4.81 an hour being paid to textile workers anywhere else," according to the industry source.

Because of the labor dispute, Stevens workers at Roanoke Rapids have not received raises given to other Stevens employes. But the company plans to make its Roanoke employes "whole" if and when a contract is signed, the industry source said.

Other industry sources strongly denied some union claims that Stevens has been hurt by the four-year national boycott.

"The company posted record gains for each quarter since the boycott began," one of the industry sources said.For example, according to the source, Stevens' profits increased from $36.4 million in fiscal 1978 to more than $48 million in 1979.